Bool type - can't it be zero / nonzero?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Jun 8 10:47:32 PDT 2008


"Chris Wright" <dhasenan at gmail.com> wrote in message 
news:g2gp5a$n1m$1 at digitalmars.com...
> celopmuh wrote:
>> From what I gathered, the inconsistency in using bool/int types is for 
>> the sake of optimization, and int logical values work faster mainly 
>> because they're 0 / non-0, not 0/1 (so that you can use simple 
>> subtraction to compare things).
>
> The inconsistency is a compiler-specific optimization: dmd, I believe, 
> generates slow code for dealing with bools, so Walter made Object.opEquals 
> return an int.

This "tool issues drive the spec" kind of worries me.  This is not the only 
instance.  D limits the size of single blocks of data in the static data 
segment to 16MB with the rationale that "anything bigger should really be on 
the heap."  The truth seems to be that OPTLINK simply crashes or does 
something equally horrible if there is a piece of data more than 16MB in the 
static data segment.  Coincidence?
I'm worried what's next.  "D does not permit variadic templates whose 
mangled names would be longer than 4096 characters"?

Now some things are understandable.  Working on my own implementation of a 
language it's become clear that some features are simply unworkable because 
of inherent limitations of the environment in which the implementation is 
written.  But this should not have any bearing on the spec, only a note in 
the implementation notes saying that it _almost_ follows the spec but 
doesn't in this area because of some restriction. 





More information about the Digitalmars-d mailing list