Challenge (was: Re: [Squeak 0003836]: nil ~= 1and: [1 isNil] is parsed+compiled without complaint)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Challenge (was: Re: [Squeak 0003836]: nil ~= 1and: [1 isNil] is parsed+compiled without complaint)

David Faught
Bert Freudenberg wrote:
>Heh. My favourite strange expression is this:
>
># "hi there" :== '_'
>
>1) Who can guess what the result is WITHOUT trying it?
>2) Who can explain what's happening?
>3) Do we need to fix it?

Consider this a vain attempt at exposing my terrible logic and
understanding of Squeak:

Parsing from left to right, we get:
1. first the # which indicates a symbol constant following,
2. then a space, of which I'm not sure of the significance in this
context, I'll assume it is significant and in fact terminates the
therefore null symbol constant,
then a comment string,
3. another space which should not be significant in this context,
4. then the := assignment operator, which means we are assigning
something to the null symbol constant, probably not a good idea,
5. the = equality test, I'm totally guessing here, but the left side
is the partial assignment expression,
6. another insignificant space,
7. the string constant containing the underline, which I guess is
still considered to be an alternate to the assignment operator, but
inside of a string should not be evaluated that way.

So the equality test would be testing the partial assignment
expression against a string which should yield false.  In my
unenlightened view of this, there are at least 3 places where some
kind of warning or error message should be issued and prevent this
from actually being evaluated:
a. number 2, who needs a null symbol constant,
b. number 4, why should you be able to assign anything to a constant,
c. number 5, because the left side isn't a resolved expression.

Since my guess didn't nicely resolve into testing whether the two
assignment operators are equivalent, I'm thinking that I did something
wrong, but I'll leave it to someone else to explain what is the right
way.