DMD 0.170 release
Tom S
h3r3tic at remove.mat.uni.torun.pl
Tue Oct 17 16:25:03 PDT 2006
Reiner Pope wrote:
> Tom S wrote:
>> void each(int[] a, void delegate(int) dg, inout void* ret) {
> It would be good to support non-void delegates as well, for things with
> predicates, like map, fold, and sort:
>
> int fold(int[] a, int start, void delegate(int, int) dg, inout void* ret)
>
> and
>
> fold(myList, 0) (a, b) { yield a + b; } // Yield returns a value from
> the delegate, as opposed to returning from the enclosing function
I think it's a great idea and it adds a whole new dimension to the
proposal !
> Note that with some predicates shouldn't be able to control the flow of
> code, so I think that last parameter (inout void* ret) should be
> optional -- if the last parameter is a delegate, then break and return
> can't be used within the delegate.
Another good idea :)
>> each (arr) (int a) {
> Of course, this should be type-inferred so you just need to write
>
> each (arr) (a) { ... }
> or
> arr.each (a) { ... }
Sure thing :)
I'm not yet fully convinced if trailing delegates should be allowed
implicitly, just because a function's signature matches some criteria. A
special keyword like 'trailing' could be used for it. Of course, because
of a lack of a better keyword at the moment, we could just call it
'static' <g>
--
Tomasz Stachowiak
More information about the Digitalmars-d-announce
mailing list