Minor extension to cast syntax

BCS BCS at pathlink.com
Wed Oct 31 14:26:39 PDT 2007


Gregor Richards wrote:
> Gregor Richards wrote:
> 
>>> There is that idea in language design that if it can be done as a 
>>> function it should be unless there is a good reason not to.
>>
>>
>> In highly dynamic languages where performance isn't a primary 
>> objective, yes. Dynamic arrays, anyone?
>>
> 
> I should also mention, while I'm at it, that this can NOT be done as a 
> function.
> 
>  - Gregor Richards


you sort of can. Allow static virtual member function
and then let types (including built in's) define
opCastFrom's Then this

cast(T)(r);

gets rewritten as this

T.opCastFrom(r);

where the T is a "runtime Type variable" that is in
fact just a v-tbl pointer.

Except for the static virtual member functions, if any
of that gets implemented I will fly out to Seattle and
throw new WetSpaghetti();// at Walter.



More information about the Digitalmars-d mailing list