News for hackers. Stuff that matters.
Re:A Week with Mozilla's Rust by acqq on Wednesday August 21, 2013 @06:05PM (#6253619)
Can I ask in the language if the address points to the item constructed by the compiler in the static area?

The thing I miss most in C is the possibility for the some kind of"introspection" -- reaching out to the info that the compiler or linker has to know anyway. As far as I know D language is very good for such things.

Re:A Week with Mozilla's Rust by dbaupp on Wednesday August 21, 2013 @08:29PM (#6254278)
You can use lifetimes to enforce that a certain thing is static data, and combined with an enum, you get the best of both worlds: compile-time constants require no allocations, but still flexible enough to allow run-time construction:

  enum StringRef {
      Static(&'static str),
      Owned(~str)
  }
and then `error` would take `StringRef` and be called like:

  self.error(Static("trailing characters"))
  // or
  self.error(Owned(fmt!("%u trailing characters", count)))
(There was even a pull request that added this and the corresponding one for vectors to the stdlib, but it didn't landed (yet): https://github.com/mozilla/rust/pull/7599)
Re:A Week with Mozilla's Rust by pcwalton on Wednesday August 21, 2013 @06:10PM (#6253640)
> Ca I ask in the language if the address points to the item constructed by the compiler in the static area?

It'd require some OS-specific magic. But you could probably do it.