class extensions
Nathan Reed
nathaniel.reed at gmail.com
Thu Aug 30 16:01:03 PDT 2007
Bill Baxter wrote:
> Chris Nicholson-Sauls wrote:
>> Bill Baxter wrote:
>>> kris wrote:
>>> So my feeling is that for this to be more useful:
>>> 1) Extension members should be marked as such and *only* be allowed
>>> to be called with member syntax. Those not marked as such will not
>>> be allowed to be called with member syntax. (if you need both then
>>> it's easy enough to write a trivial forwarding function.)
>>
>> Its not a bad idea. The "trivial forwarding function" should be
>> inlineable anyhow. Maybe a "context" parameter? Something like:
>> size_t indexOf : T[] array (T) (T elem) { ... }
>>
>> Where the (':' param) after the function name creates the
>> context-param. Other examples:
>>
>> ulong area : IShape shp () { ... }
>>
>> void unique : inout T[] array (T) () { ... }
>>
>>
>> Its just a random on-the-spot idea.
>>
>
> Maybe even just use a semi-colon instead of comma in the arg list?
> size_t indexOf(T)(T[] array; T elem) { ... }
> ulong area (IShape shp;) { ... }
> void unique (ref T[] array; T) () { ... }
>
> --bb
I like that syntax; something similiar is used in mathematics on
occasion. Simple and elegant.
Thanks,
Nathan Reed
More information about the Digitalmars-d
mailing list