byKey and byValue: properties or methods?

Timon Gehr timon.gehr at gmx.ch
Wed Jan 18 18:18:22 PST 2012


On 01/19/2012 01:52 AM, Jonathan M Davis wrote:
> On Thursday, January 19, 2012 01:38:23 Alex Rønne Petersen wrote:
>> But couldn't that be considered leaking an implementation detail of lazy
>> values? Or is this intentional design?
>
> The language requires that lazy parameters be accessed with (). That leaks the
> fact that the variable is lazy into the function body, but whether it leaks
> how lazy parameters are implemented is debatable. The same syntax could be
> used with a different implementation underneath the hood.
>
> But the fact that you have to use double parens on a lazy delegate isn't
> leaking any kind of implemenatation detail. It's the natural extension of the
> syntax for lazy. var() gives you the value of the lazy parameter var, and so
> if you want to call var (or use opCall or it), then you need another set of
> parens - var()().
>
> Whether requiring parens on lazy parameters is a good design decision is
> debatable,

They are only required if you want to call a lazy delegate/function 
pointer. They are optional in all other cases.

> but I don't see any leaking of implementation details in it. The
> syntax chosen was probably chosen because it's implemented with a delegate,
> but the fact that it's implemented with a delegate is still an implementation
> detail which could theoretically be changed.
>




More information about the Digitalmars-d mailing list