[Bug 186] New: 'and' and 'or' as alternatives for && and ||
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 8 10:55:07 PDT 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=186
Summary: 'and' and 'or' as alternatives for && and ||
Product: D
Version: 0.157
Platform: Macintosh
OS/Version: Mac OS X
Status: NEW
Severity: enhancement
Priority: P5
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: barnaby at daltonsgate.com
example:
if("aardvark" < "zebra" and "C" < "D")
writefln("all is right in the world");
I've found this is a small change that really helps. Especially when it has
lower precedence than &&, ||.
For example:
while(obj = getobj() && good(obj)) { ... }
actually means:
while(obj = (getobj() && good(obj)) { ... }
with the C precedence. This doesn't compile (unless obj is a boolean).
With lower precedence, the extra brackets would not be needed for this
to give the natural interpretation. I find this pattern comes up commonly,
and I miss it from higher level languages like Ruby.
--
More information about the Digitalmars-d-bugs
mailing list