[M3commit] CVS Update: cm3

Tony Hosking hosking at cs.purdue.edu
Tue Jan 26 00:32:30 CET 2010


Finally got a chance to check this out.
It turns out that the expression

-FIRST(INTEGER)

actually does overflow at compile time, so it is actually a compile-time error to write:

CONST v = -FIRST(INTEGER);

Even worse, on a system where overflow causes a trap that code in Lex.m3 would have failed.

The expression you wrote doesn't overflow at compile-time, so it is much safer, allowing:

CONST v = Word.Plus(-(FIRST(INTEGER)+1), 1);

Good catch!

On 24 Jan 2010, at 05:57, Jay K wrote:

> Imagine if FloatMode worked.
> And if the compile-time evaluation wasn't performed.
> This code would fail.
>  
>  
> Though really..you know.. I don't think making FloatMode work makes sense.
> It should be an interface/type thing that determines statically at compile time
> if overflow is trapped.
>  
>  
>  - Jay
>  
> > From: hosking at cs.purdue.edu
> > Date: Sun, 24 Jan 2010 04:28:01 -0500
> > To: jkrell at elego.de
> > CC: m3commit at elegosoft.com
> > Subject: Re: [M3commit] CVS Update: cm3
> > 
> > I really don't like this...
> > what's wrong with allowing compile-time overflow other than that it exposes 2-s complement representation?
> > 
> > On 23 Jan 2010, at 20:42, Jay Krell wrote:
> > 
> > > CVSROOT: /usr/cvs
> > > Changes by: jkrell at birch. 10/01/23 20:42:28
> > > 
> > > Modified files:
> > > cm3/m3-libs/libm3/src/fmtlex/: Lex.m3 
> > > 
> > > Log message:
> > > oops 1 => 1L
> > 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20100125/1476adc7/attachment-0002.html>


More information about the M3commit mailing list