The Status of Const

dsimcha dsimcha at yahoo.com
Fri Aug 13 17:45:13 PDT 2010


== Quote from Jonathan M Davis (jmdavisprog at gmail.com)'s article
> On Friday, August 13, 2010 16:30:46 dsimcha wrote:
> > I still don't understand:  What's so bad about Rebindable?  Yes, it's not
> > the syntactically prettiest thing in the world, but complaining about it
> > is like complaining about climbing a molehill when you've got Mount
> > Everest to climb next. My previous gripe about it was that it didn't
> > support interfaces, but I just realized that Shin Fujishiro fixed this a
> > while back.
> Well, first of all, the code is much uglier with it, though that's arguably a
> fairly superficial complaint. Part of it is the fact that it really _should_ be
> in the language itself rather than having to use Rebindable. Honestly, I haven't
> messed with it in a while, so I don't remember all of the issues. I've never
> liked it, and I've always had trouble in getting it to work. Now, maybe that's
> totally due to bugs that may be fixed now, but it's always been problematic, and
> certainly my gut reaction is that the type system is deficient because it can't
> do it itself. Having to use Rebindable!() is definitely worse than being able to
> do things like const (T)*. But maybe with all of the bugs worked out and just
> getting used it, it's a good and reasonable solution. Honestly though, I've
> never been able to get it to work right, and I've never been happy about the
> fact that the type system can't handle it itself. Obviously, I need to go back
> and try and use it again. However, with inout broken and Object not being const-
> correct, I'm not sure that I'll get very far with using const and immutable
> anyway. Still, it would be so nice if it could just be handled cleanly by the
> type system.
> - Jonathan M Davis

http://dsource.org/projects/phobos/changeset/1849

I've added some trivial convenience functions to Phobos that should have been
there a long time ago and should go a long way towards making Rebindable more
usable.  The other thing we need is bug fixes in alias this/opDot, which we need
eventually anyhow.  Now, instead of doing something like this ugly, verbose,
specify-things-twice code:

auto foo = Rebindable!(LongTypeName)(new LongTypeName);  // Shoot me.

You can do:

auto foo = rebindable(new LongTypeName);  // Sanity restored.



More information about the Digitalmars-d mailing list