"instanceOf" trait for conditional implementations
monarch_dodra
monarchdodra at gmail.com
Thu Oct 4 05:47:46 PDT 2012
On Thursday, 4 October 2012 at 12:48:51 UTC, so wrote:
> On Thursday, 4 October 2012 at 09:43:08 UTC, monarch_dodra
> wrote:
>
>> The current implementation for "isAssignable" is
>> //----
>> template isAssignable(Lhs, Rhs)
>> {
>> enum bool isAssignable = is(typeof({
>> Lhs l = void;
>> void f(Rhs r) { l = r; }
>> return l;
>> }));
>> }
>
> OT - Is there any reason for disabling UFCS for this?
>
> template isAssignable(Lhs, Rhs)
> {
> enum bool isAssignable =
> {
> Lhs l = void;
> void f(Rhs r) { l = r; }
> return l;
> }.typeof.is;
> }
Because typeof is a keyword, and is is a declaration.
There are two open ER to allow typeof to be used as a property:
While not strictly EFCS, it would be convenient.
Regarding is, There are no open requests. But I guess it would be
fun to write
if( T.is(U) ).
But where would it end? Make if UFCS too?
T.is(U).if()
IMO, I can see typeof being a property, but not is.
More information about the Digitalmars-d
mailing list