Shortcuts

James Dunne james.jdunne at gmail.com
Sun Feb 26 08:51:37 PST 2006


Trevor Parscal wrote:
> In article <dtsl1i$1n4e$1 at digitaldaemon.com>, Trevor Parscal says...
> 
>>I just wrote a new templated shortcut module for Fusion - and I thought I would
>>suggest inclusion in phobos - since it's so darn handy. Some might think this
>>isn't their style - but it can be useful in making things look nice and clear
>>IMHO.
>>
>>The idea is that you can have "multi" argument properties like...
>>
>>/////////////////////////////////
>>class FOO
>>{
>>int[] Range(int[] _values)
>>in
>>{
>>asert(_values.length >= 2);
>>}
>>body
>>{
>>this.start = _values[0];
>>this.end = _values[1];
>>return _values;
>>}
>>}
>>/////////////////////////////////
>>
>>and than you can use the property like...
>>
>>/////////////////////////////////
>>
>>foo.Range = pair(1, 10);
>>
>>/////////////////////////////////
>>
>>There are 3 shortcuts. all deal with values of a single type.
>>
>>pair has 2 arguments, and always returns a dynamic array with 2 elements.
>>trio has 3 arguments, and always returns a dynamic array with 3 elements.
>>list is variadic, and always returns a dynamic array with at least 1 element.
>>
>>The code can be seen on the dsource svn...
>>
>>http://svn.dsource.org/projects/terra/trunk/Fusion/Source/Fusion/Composite.d
>>
>>The source is free as in beer - just let your buddies know who gave you the
>>beer!
>>
>>Thanks,
>>Trevor Parscal
> 
> 
> OR perphaps not - I was messing with it allot more, using different types, and
> allot of casting is needed to support all types.. so - I guess this will never
> really work on a generic level.
> 
> Sorry for posting before testing extensively... I get excited sometimes.. :)
> 
> Thanks,
> Trevor Parscal

Hehe.  Understood.

-- 
Regards,
James Dunne



More information about the Digitalmars-d mailing list