On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote:
Hello. I have always loved the readability of C++'s
and/or/not/xor
word-like logical operators but It doesn't seem to be available
in D.
Isn't this possible in D? I tried doing:
alias && and ;
import std.stdio ;
void main () {
writeln ( true and true ) ;
}
but I get errors:
$ dmd foo.d
foo.d(1): Error: basic type expected, not &&
foo.d(1): Error: no identifier for declarator int
foo.d(1): Error: semicolon expected to close alias declaration
foo.d(1): Error: Declaration expected, not '&&'
foo.d(7): Error: found 'and' when expecting ',
Thanks.
For better or worse, we don't have those keywords in D and are
unlikely to get them.
Also, alias is not the same as the C preprocessor, you can't
redefine any arbitrary string you want.
http://dlang.org/declaration.html#alias