Remus

Namespace rswhite4 at googlemail.com
Wed Nov 21 09:29:39 PST 2012


> I think they are fully implementable in library code. Maybe
> Phobos Array already does that fully.
>
> While Variable Length Arrays allocated on the heap can't be
> implemented with a nice syntax in library code, so I think they
> are more fit for a built-in implementation (but they need new
> syntax and they are more complex to implement).
Hm, I like scope int[i] arr; I will think about it.

> This is a quite common need, like when you want to perform a
> costly computation only once. Maybe there is even an enhancement
> request in Bugzilla.
>
> I understand why this is named "lazy const" but this code is
> currently accepted:
>
> void foo(lazy const int x) {}
> void main() {}
Oh good point, thanks.

> So to avoid confusion I suggest to give a different name to this
> feature. One possibility is to use a new keyword, like a
> "monoassignable" :-)
Then preferably "readonly" or something like this. :D Or just 
'mono'.

> How did you implement this feature? If done well, with a good
> enough name, it's even possible to make a pull request in the
> main D compiler with just this feature.
I don't understand. What do you mean with 'how'? I will write a 
struct and replace 'readonly ...' with an instance of 
ReadOnly!(...) ...

> Probably this requires far more design to be done well enough.
>
> I suggest to write/adapt several small programs with your new
> features (like from here:
> http://rosettacode.org/wiki/Category:D), and to try them to see
> how useful they are.

What do you mean with 'how useful'?


More information about the Digitalmars-d-announce mailing list