Remus
bearophile
bearophileHUGS at lycos.com
Wed Nov 21 07:20:08 PST 2012
Namespace:
> - scope arrays: like static arrays,
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).
> - lazy const: Just a spontaneous idea: I have often variables,
> which aren't initialize in the CTor, but they are initialized
> only once, and then they should be constant. That isn't
> possible yet. Therefore I whish something like: lazy const var;
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() {}
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" :-)
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.
> - And of course: not-null references. There is not much to
> say. Current syntax idea comes from C++: Foo& f = other_f;
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.
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list