The future of lambda delegates
Bruno Medeiros
brunodomedeirosATgmail at SPAM.com
Wed Aug 16 15:34:49 PDT 2006
Oskar Linde wrote:
>
> What could improve things is if there was a no-immigrants (only visitors)
> declaration for function arguments that guaranteed that any escaping
> delegate passed to one such function argument would never be stored after
> that function returns or be passed as argument to any other immigration
> friendly function:
>
> void update(int[] arr, visitor void delegate(inout int a) updater) {
> foreach(inout i;arr)
> updater(i);
> }
>
> ....
> int b = ...;
> myarr.update((inout int a) { a += b; });
> // would not count as an escape and would not need b to be stack allocated
>
> /Oskar
>
Whoa... if I'm not mistaken that is kinda like the converse of
const(read-only): it is a write-only (or use-only) variable. It's value
cannot be read (at least directly) :
mydg = updater; // cannot be read!
updater(i); // but can use;
updater = xpto; // and can assign to?
:D
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list