[M3devel] Mixed arithmetic

Tony Hosking hosking at cs.purdue.edu
Tue Jan 12 03:18:00 CET 2010


On 11 Jan 2010, at 20:21, Jay K wrote:

> 
>> rather than having things
>> happen behind the scenes, without the programmer's coding them
> 
> 
> Just a reminder that things happen behind the scenes *all the time*.
> It is the norm, not the exception.
> Look at what "try" does.
>  It is two or three function calls.

Conceptually it need not be.  Moreover, the effects are not something the programmer needs to reason about.

> Look at the garbage collector. 

Again, that is not visible to the programmer.  Same again re programmer reasoning.

> Look at layering in various places.
> The system is not simple.
> This isn't a bad thing necessarily.
> Getting things done often requires complexity.
> I haven't finished listening to "growing a language" but Steele makes the point that if your language is too small, it is very limiting in what you can elegantly do or do at all.

His conclusion is interesting, and reflects the decision to grow Java not by language extension but by library extension.

> Promoting an INTEGER to a LONGINT is among the simplest things you can do probably.
> 
> 
> It is simpler in fact than adding 1 to an integer, because it cannot fail, whereas adding 1 can.

Let's enumerate some complexity.

What does LAST(INTEGER) + 1 mean?
What about LAST(INTEGER) + 1L?

Why should they mean something different?  Let's assume that it's all just values.  Then we want the same interpretation for both expressions.  But we must live in the real world where the meaning of "+" must be implemented using the limited integer range of the machine.

I think that the status quo is a reasonable place to be.  Yes, it means that you have to write VAL(LAST(INTEGER), LONGINT) + 1L to get something different than LAST(INTEGER)+1, but at least it retains referential transparency.

I strongly support the status quo.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100111/02734d2d/attachment-0002.html>


More information about the M3devel mailing list