[OT] Writing a parser for BASIC in Smalltalk/Squeak ? (<CSOTD > included)

Withers, Robert rwithers at quallaby.com
Wed Jan 9 19:25:41 UTC 2002


I agree, Henrik.  I view this scenario as synonomous as the behavior of the
expression (i++) in c++.  Could we consider that evaluating an expression
creates a temp closure of virtual bindings, based on precedence rules?

How about:
| m n |
n _ 2.
m _ 3.
n _ (m _ n) + m

??

What would C++ or Java do in the original example?  How about Haskell?

	addVectors(m, m = n);

with
	addVectors(Vector x, Vector y);    // like squeak
or
	addVectors(Vector& x, Vector& y);    // oops

It seems that we have implicit pass-by-value, since we don't even have
references!

rob

> -----Original Message-----
> From: Henrik Gedenryd [mailto:h.gedenryd at open.ac.uk]
> Sent: Wednesday, January 09, 2002 2:08 PM
> To: squeak-dev
> Subject: Re: [OT] Writing a parser for BASIC in Smalltalk/Squeak ?
> (<CSOTD> included)
> 
> 
> Tim Rowledge wrote:
> 
> >> Indeed. I wonder if this behaviour is actually defined 
> somewhere? It's at
> >> least counter-intuitive.
> > [snips]
> >>>> | m n |
> >>>> n _ 2.
> >>>> m _ 3.
> >>>> n _ m + (m _ n)
> > That's a very polite way of putting it!
> > 
> > Looking at the bytecodes of the method clearly show why it 
> happens and
> > I think it must count as a pretty nasty bug.
> 
> Sorry, I must protest. This is entirely to be expected, as this is
> "call-by-value" or whatever is the proper name, as vs. 
> call-by-reference or
> some such. A variable holding an integer refers to that 
> integer object,
> which is pushed, then another integer object is pushed when 
> that has become
> the new value of the variable.
> 
> Henrik
> 
> 
> 




More information about the Squeak-dev mailing list