Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 01, 2010 2 little enigmas with is & Unqual! | ||||
---|---|---|---|---|
| ||||
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) 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 ;-) Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com |
December 01, 2010 Re: 2 little enigmas with is & Unqual! | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | 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 > 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 hope this can help.... > Denis > -- -- -- -- -- -- -- > vit esse estrany ☣ > > spir.wikidot.com > |
December 01, 2010 Re: 2 little enigmas with is() & Unqual! | ||||
---|---|---|---|---|
| ||||
Posted in reply to vincent picaud | On Wed, 01 Dec 2010 10:03:57 -0500 vincent picaud <vincent.picaud@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 |
December 01, 2010 Re: 2 little enigmas with is() & Unqual! | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | spir Wrote: > On Wed, 01 Dec 2010 10:03:57 -0500 > vincent picaud <vincent.picaud@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? Perhaps... I will check at home with dmd/windows, here I only gdc/linux > > > 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? I think it is the right reason, is() does not support "!=", only "==" > > hope this can help.... > > Yes, helps a lot, thank you Vincent. Thank, I m a new comer here, :) > > > Denis > -- -- -- -- -- -- -- > vit esse estrany ☣ > > spir.wikidot.com > |
Copyright © 1999-2021 by the D Language Foundation