[ENH] UpArrow as operator (was: Must _ go like the Dodo?)

Travis Griggs tgriggs at keyww.com
Thu Mar 18 06:47:50 UTC 1999


Doug Way wrote:

> On Wed, 17 Mar 1999, Bert Freudenberg wrote:
>
> > Doug Way wrote:
> >
> > > I guess a better argument for using something other than ^ for returning
> > > is that you could then use ^ in place of raisedTo:, e.g. x^2, which is
> > > semi-standard typed-math notation.  (When was this introduced?)  Still,
> > > it ain't gonna happen. :-)
> >
> > What's not gonna happen? Using ^ as an operator is as easy as using |
> > (there is code in the parser to special-case the vertical bar).  The
> > attached changeset patches the parser and adds Number>>#^ to give the
> > expected result ...
>
> Sorry, by "ain't gonna happen" I just meant that I didn't think the ^ was
> ever going to be removed as the return symbol.  You've certainly proved
> that it's possible to use it for both the return symbol and an operator!
> (I guess I should have thought of that, since the parser can determine
> whether the ^ is the first part of a statement or not...)

Of course, this could result in some head scratching confusion. Consider the two
following methods:

methodA
    self doSomeCode.
    self doSomeMoreCode.
    self funStuff
    ^aResult

methodB
    self doSomeCode.
    self doSomeMoreCode.
    self funStuff.
    ^aResult

See the difference? No longer will one be warned about end of statement list
expected when accepting methodA, instead a runtime exception stating that
whatever results from funStuff doesNotUnderstand ^.

--
Travis Griggs (a.k.a. Lord of the Fries)
Key Technology
tgriggs at keyww.com
Member, Fraven Skreiggs Software Collective
 - C for Sinking
 - Java for Drinking
 - Smalltalk for Thinking
 ...and Power to the Penguin!





More information about the Squeak-dev mailing list