2 little enigmas with is() & Unqual!
spir
denis.spir at gmail.com
Wed Dec 1 08:17:37 PST 2010
On Wed, 01 Dec 2010 10:03:57 -0500
vincent picaud <vincent.picaud at laposte.net> wrote:
> spir Wrote:
>
> > Hello,
> >
> > 1. Why isn't Unqual!(char) == char?
> > writeln( is( Unqual!(typeof('c')) == char ) ); // false
> > writeln( is( Unqual!(char) == char ) ); // false
> > writeln( is( char == char ) ); // true!
> > (dmd v2.049)
> >
>
> Using GCD 4.3.5 ( more precisely on Linux/Debian )
>
> writeln( is( Unqual!(typeof('c')) == char ) );
> writeln( is( Unqual!(char) == char ) );
> writeln( is( char == char ) );
>
> returns
>
> true
> true
> true
>
> as expected
All right, I do not have the same results using dmd. Seems like abug, doesn't it?
> > 2. Why cannot one write "assert(is(Unqual(t1) == t2))"?
> > assert( is( char == char ) ); // OK
> > assert( is( Unqual!(char) != char ) ); // compile Error
> > assert( is( Unqual!(typeof('c')) != char ) ); // compile Error
> > (is() gets on my nerves ;-)
> >
>
> not sure of that, but I think "is" is a compile time feature, hence you must write
> static assert( is( char == char ) ); // OK
> static assert( is( Unqual!(char) == char ) ); // OK
> static assert( is( Unqual!(typeof('c')) == char ) ); // Ok
Well, on dmd:
static assert( is( Unqual!(char) == char ) );
raises:
Error: static assert (is(Unqual!(char) == char)) is false
which is at least consistent with the result written above. But strangely, I cannot reverse the predicate:
static assert( is( Unqual!(char) != char ) );
yields:
found '!=' when expecting ')'
Actually, i even cannot write:
static assert( is( char != dchar ) ); // same error
Is this normal? Doesn't is() allow != at all?
> hope this can help....
Yes, helps a lot, thank you Vincent.
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list