Hidden argument kind antipattern
Robert Jacques
sandford at jhu.edu
Tue Apr 19 20:49:46 PDT 2011
On Tue, 19 Apr 2011 19:47:57 -0400, Vladimir Panteleev
<vladimir at thecybershadow.net> wrote:
> On Wed, 20 Apr 2011 02:43:50 +0300, bearophile
> <bearophileHUGS at lycos.com> wrote:
>
>> I agree. In my opinion the problem is not you using in your module a
>> language feature designed for that very purpose. What's in question is
>> the syntax of that language feature. I don't mind lazy arguments, but
>> it can be argued that's better for them to require a "lazy" prefix at
>> the calling point too. This little syntax problem that was already
>> raised during the D2 design phase.
>
> I would like to clarify my point:
>
> Inarguably (IMO), the original intention of lazy parameters was to allow
> passing expressions to functions that were evaluated only when required.
>
> David's library evaluates these expressions *in different threads*!
>
> Generally, I would count that any usage of "lazy" counts as abuse except
> for evaluating the argument, at most once, during the function's
> execution.
>
Lazy is also good at abstracting error handling. For example, I use lazy
to perform smart C error code checking, which allows me to handle certain
common errors and then re-try the function.
More information about the Digitalmars-d
mailing list