[ENH] Display := when pretty printing ([sm][et][er][cd][approved] )

Peter van Rooijen peter at vanrooijen.com
Fri Oct 17 10:20:50 UTC 2003


From: "Richard A. O'Keefe" <ok at cs.otago.ac.nz>

Hi Richard,

It's a bit difficult making out what exactly was said by whom because your
news client doesn't seem to have done any indenting. I'll put in some tags
to hopefully make it clearer who said what.

> "Peter van Rooijen" <squeak at vanrooijen.com> replied:
> Sure, [ANSI Smalltalk] has problems.  But not so many that it
> can't be extremely useful anyway.

R:
To repeat what I wrote in a different way:  it is a badly written
description
of a very useful thing.  We agree.

We agree that it's very useful. But I'm not as critical as you of how well
it was written. I've read large parts several times, and I've built a tool
that analyzes the ANSI Smalltalk standard type library, so I have seen quite
a lot of the document.

Even though it's not always as clear or as consistent as it might have been,
I don't think there are many instances where, let's say, an implementor
building a compliant implementation, would be lost for lack of guidance.

> > The ANSI Smalltalk standard says that "_" is a character that is usable
> > in identifiers.  I think this is a Good Thing and I would like Squeak to
> > support it.
>
> That is a very good example.  Squeak could easily support it.
> Why it is not done?  I don't know.
>
> Because "x_y z" means "x := y z" in Squeak whereas it would have to
> mean "(x_y) z" in ANSI Smalltalk, where x_y is a single identifier.

x_y z would only be problematic if all three of x, y, and x_y were in scope,
right? Otherwise, there would be no ambiguity. So, only in the particular
circumstance of all three names being in scope, would one need to
disambiguate by either putting whitespace next to the _ or, alternatively,
use := for the assignment. In all other cases, there is no ambiguity anyway.

In view of the fact that existing Squeak code can't use identifiers with
underscores in them, it seems to me that _all_ existing code would still be
valid if underscores in identifiers would be allowed from now on.

And in new code, those who like to assign with underscores with no
whitespace around them, can even continue doing so, as long as they don't
have x, y, and x_y in scope, which might well mean that they will never
write an unintended ambiguity in their entire careers. Should it happen
anyway, a simple space will suffice to clear things up.

So, I maintain my position that Squeak could easily support underscores in
identifiers.

Please tell me if I missed something.

> > Note, by the way, that ":=" is incompatible with mathematical usage.
>
> 'Incompatible'? In which way is it incompatible with that? Perhaps you
> simply mean 'different'?
>
> No, I mean "incompatible".
> "Change the value of x" and "Permanently define x" are quite incompatible
> readings.  They aren't just different, they are contradictory.

When you say 'incompatible', that suggests, I believe, that somehow they
should, or could be expected to, be 'compatible'. But one is a notation for
mathematics, the other for computer programs. Why should there be an
expectation of compatibility?

Anyway, it's not a big deal to me.

> > In mathematics "x := y" doesn't mean "change x to have y as value",
>
> It doesn't mean that in Smalltalk either.
>
> Yes it does.  The purpose of assignment is precisely to change the
variable
> on the left hand side.  It'd be a funny kind of assignment that _didn't_
> change the variable.  (It doesn't change the _name_ of the variable, of
> course.)

Sure, assignment does have exactly that purpose. But it doesn't make y be
the value of x, it makes *the value of y* be the value of x. But, I'm just
teasing you. I knew perfectly well that you didn't intend to say that the
variable y itself was being assigned to x.

[snip ASCII/Unicode]

Regards,

Peter van Rooijen
Amsterdam




More information about the Squeak-dev mailing list