Re: [C--] bool and bits1

Ning Wang <[email protected]> Sun, 22 Mar 2009 10:50:33 -0700
Newsgroups gmane.comp.lang.c--
Message-ID <[email protected]>
Norman Ramsey wrote:
>  > bool type is not uncommon in high level programming languages.  How does 
>  > it map to a C-- type?  Without bool type in C--, a bool type has to be 
>  > converted to bits1 and then convert back later.
>
> It depends whether the bool type is used in a value context or a
> control-flow context.  In my front ends, a boolean in a value context
> is compiled to bits32 and a boolean in a control-flow context is
> compiled to control flow.  
This handling makes sense for C. But in other type safe languages, a 
bool value, no matter where it is defined,  will eventually be used in 
control-flow contexts or not used at all.  

> But that's because I'm interested in
> polymorphic languages where every value is the same size.  How you
> compile Booleans is really your choice; the point is that there are no
> Boolean registers on modern machines, so there are no Boolean
> *variables* in C--.  There are only Boolean *expressions*, and these
> may appear only in control-flow contexts.
>   
I'm not so sure that polymorphic languages and values of different sizes 
are contradict concepts. Can Cyclone be counted as a polymorphic 
language?  It has values of different  size.

Yes, there are no bool registers in modern machines, but C-- modes an 
abstract machine right?  IMHO, adding pseudo bool registers can simplify 
the work of front-ends.  Code generator can map it to whatever registers 
are available in target machines.

Thanks,
Ning
_______________________________________________
Cminusminus mailing list
[email protected]
https://www.eecs.harvard.edu/mailman/listinfo/cminusminus