syntax idea: simplifed ifs
BCS
BCS_member at pathlink.com
Thu Apr 13 13:24:18 PDT 2006
Bruno Medeiros wrote:
> Derek Parnell wrote:
>> On Mon, 10 Apr 2006 18:03:57 -0600, Hasan Aljudy wrote:
>>> dennis luehring wrote:
>>>
>>>> if( x == 10 && x == 20 && x == 30 )
>>>> simplified:
>>>> if( x == [10 && 20 && 30] )
>>>>
[...]
>>>
>>> hmm, come to think of it, maybe it can already be implemented with
>>> templates.
>>>
>>> so,
>>>
>>> if( x == 10 || x == 20 || x == 30 )
>>>
>>> becomes:
>>> if( equals!(x).anyOf( 10, 20, 30 ) )
>>>
> In the template example? Why did both of you think a template was
> necessary? One can do this with plain old functions. Well, with typesafe
> variadic functions that is:
> equalsAny( x + y, 10, b, c)
> also possible (but somewhat weird..) :
> equals(x + y).AnyOf(10, b, c)
>
> Or am I missing something terribly obvious? :o
>
>
templates insure inlining and provide more options for optimization. not
terribly critical but...
More information about the Digitalmars-d
mailing list