class extensions
Bill Baxter
dnewsgroup at billbaxter.com
Thu Aug 30 14:16:49 PDT 2007
Chris Nicholson-Sauls wrote:
> Bill Baxter wrote:
>> kris wrote:
>>> Lutger 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
More information about the Digitalmars-d
mailing list