digitalmars.D.learn - 2 little enigmas with is & Unqual!
- spir (15/15) Dec 01 2010 Hello,
- vincent picaud (15/35) Dec 01 2010 Using GCD 4.3.5 ( more precisely on Linux/Debian )
- spir (22/58) Dec 01 2010 All right, I do not have the same results using dmd. Seems like abug, do...
- vincent picaud (4/69) Dec 01 2010 I think it is the right reason, is() does not support "!=", only "=="
Hello, 1. Why isn't Unqual!(char) =3D=3D char? writeln( is( Unqual!(typeof('c')) =3D=3D char ) ); // false writeln( is( Unqual!(char) =3D=3D char ) ); // false writeln( is( char =3D=3D char ) ); // true! (dmd v2.049) 2. Why cannot one write "assert(is(Unqual(t1) =3D=3D t2))"? assert( is( char =3D=3D char ) ); // OK assert( is( Unqual!(char) !=3D char ) ); // compile Error assert( is( Unqual!(typeof('c')) !=3D char ) ); // compile Error (is() gets on my nerves ;-) Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 01 2010
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 expected2. 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 hope this can help....Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com
Dec 01 2010
On Wed, 01 Dec 2010 10:03:57 -0500 vincent picaud <vincent.picaud laposte.net> wrote:spir Wrote: =20All right, I do not have the same results using dmd. Seems like abug, doesn= 't it?Hello, =20 1. Why isn't Unqual!(char) =3D=3D char? writeln( is( Unqual!(typeof('c')) =3D=3D char ) ); // false writeln( is( Unqual!(char) =3D=3D char ) ); // false writeln( is( char =3D=3D char ) ); // true! (dmd v2.049) =20=20 Using GCD 4.3.5 ( more precisely on Linux/Debian ) =20 writeln( is( Unqual!(typeof('c')) =3D=3D char ) ); =20 writeln( is( Unqual!(char) =3D=3D char ) ); =20 writeln( is( char =3D=3D char ) ); =20 =20 returns=20 =20 true true true =20 as expectedust write2. Why cannot one write "assert(is(Unqual(t1) =3D=3D t2))"? assert( is( char =3D=3D char ) ); // OK assert( is( Unqual!(char) !=3D char ) ); // compile Error assert( is( Unqual!(typeof('c')) !=3D char ) ); // compile Error (is() gets on my nerves ;-) =20=20 not sure of that, but I think "is" is a compile time feature, hence you m=static assert( is( char =3D=3D char ) ); // OK static assert( is( Unqual!(char) =3D=3D char ) ); // OK static assert( is( Unqual!(typeof('c')) =3D=3D char ) ); // OkWell, on dmd: static assert( is( Unqual!(char) =3D=3D char ) ); raises: Error: static assert (is(Unqual!(char) =3D=3D 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) !=3D char ) ); yields: found '!=3D' when expecting ')' Actually, i even cannot write: static assert( is( char !=3D dchar ) ); // same error Is this normal? Doesn't is() allow !=3D at all?=20hope this can help....Yes, helps a lot, thank you Vincent. Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 01 2010
spir Wrote:On Wed, 01 Dec 2010 10:03:57 -0500 vincent picaud <vincent.picaud laposte.net> wrote:Perhaps... I will check at home with dmd/windows, here I only gdc/linuxspir Wrote:All right, I do not have the same results using dmd. Seems like abug, doesn't it?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 expectedI think it is the right reason, is() does not support "!=", only "=="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?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 ) ); // OkThank, I m a new comer here, :)hope this can help....Yes, helps a lot, thank you Vincent.Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com
Dec 01 2010