[PROPOSAL] Disallow // and \\ in Slang code (was: Re: Squeakarcheology - quo vs. //)

Andreas Raab andreas.raab at gmx.de
Wed Apr 7 13:38:04 UTC 2004


> How about we disallow // and \\ in the Slang translator to make sure
> that anyone using it is aware of the differing semantics? We would
> introduce #div: and #mod: generating explicit code rounding towards
> negative infinity and use #quo: and #rem: to get the C99 meaning. The
> error message when translating code with // or \\ should explain the
> difference, and point out that in most cases one will want to use #quo:
> or #rem:.

I partly like and I partly dislike this idea. Here is an alternative:

a) To more easily remember the names (I find #quo: and #rem: impossible to
remember) let's define #div: and #mod: instead as an extension for VMMaker
and fix the code to consistently use #div: and #mod:. This allows to
*define* the meaning of division in whatever way we decide.

b) Then, for the time being, let's *define* it by saying it rounds towards
zero instead of negative infinity.

c) Then, in the VM code let's add an assertion that does the precise same
thing we have for "sizeof(int)" etc. e.g.,

    if(-7 / 4 != -1) error("This compiler rounds towards negative
infinity").
    if(-7 % 4 != -3) error("This compiler rounds towards negative
infinity").

> What this buys us is that we can rely on the simulator doing the same
> as the Smalltalk code. Which is important, IMHO.

I think it's more than that - I think it's critical.

Cheers,
  - Andreas




More information about the Squeak-dev mailing list