But... I don't want my delegates to be lazy - breeding advice
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Fri Aug 25 04:31:57 PDT 2006
BCS wrote:
> Bruno Medeiros wrote:
>> BCS wrote:
>>
>>> Andy Knowles wrote:
>>>>
>>>> 1) While in void foo(lazy int x) will x be evaluated using x() or
>>>> just x? Either one could lead to confusion.
>>>>
>>>
>>> I'd go for "x()", because
>>>
>>> 1> it more closely reflects what is actually happening.
>>>
>>> 2> it allows x to be used to refer to the delegate
>>>
>>
>> Indeed, "x()" is a better usage, however, if x is a delegate, then the
>> "x" usage will still be allowed, due to the implicit call syntax (aka
>> property syntax).
>
> Delegates can't be used with implicit call syntax. You get a "can't
> convert T delegate() to T" error.
>
> void main()
> {
> int dg() { return 1; }
>
> int i = dg;
> int delegate() t = &dg;
> i = t;
> }
>
>
>
> d.d(7): cannot implicitly convert expression (t) of type int delegate()
> to int
Hum, you're right. I was quite under the impression of the otherwise, I
wonder where I got that from. :7
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list