Constant relationships between non-constant objects

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 17 22:58:24 PDT 2014


On Wed, Jun 18, 2014 at 05:40:47AM +0000, Sebastian Unger via Digitalmars-d wrote:
> On Wednesday, 18 June 2014 at 04:38:25 UTC, Meta wrote:
> >On Wednesday, 18 June 2014 at 01:31:33 UTC, Sebastian Unger wrote:
> >There's no head const in D, but you can emulate it. This is a *very* basic
> >example that you can expand upon.
> >
> >http://dpaste.dzfl.pl/55cb22153fcc
> 
> Thanks for that link. Yes, that is close. I'd even feel reasonaly well
> about it if it was in phobos so everybody can use the mechanism
> consistently.

Pull requests are always welcome. ;-)


> It does not however, quite meet the mark of "with ease".

Why not? You can just put it in its module and import it whenever you
need it.


> But it is possibly an acceptable hack around a shortcoming in the
> language.
> Comming from C++, it's not as though I'm not used to those.
> Just a shame to have to resort to it when D is so pretty close to
> getting rid of dirty hacks more or less completely.
[...]

I don't see it as a hack, much less a dirty one. The language was
designed precisely to allow implementing this kind of user-defined
extensions easily. In fact, there has been a recent trend to move things
*out* of the core language where a library implementation suffices.


T

-- 
Computers are like a jungle: they have monitor lizards, rams, mice, c-moss, binary trees... and bugs.


More information about the Digitalmars-d mailing list