Pure higher order functions
bearophile
bearophileHUGS at lycos.com
Sat Jul 9 11:44:47 PDT 2011
Daniel Murphy:
> Only for strongly pure functions - not const pure at this point.
I see, OK.
> Still, it should make construction of immutable structures without casting a lot easier.
I presume you mean something like this ("function" is currently required if you want to add "pure" too):
void main() {
int n = 5; // mutable;
immutable data = function(in int m) pure {
class Foo {}
auto array = new Foo[m];
foreach (ref item; array)
item = new Foo;
return array;
}(n);
// use data here
}
--------------
If you have some more energy, Walter has (I think) accepted two of my enhancement requests, but they don't have a complete patch yet (both have low priority):
3827 automatic joining of adjacent strings is bad [partial patch present]
5409 Disallow (!x & y)
Bye,
bearophile
More information about the Digitalmars-d
mailing list