Precedence (was too long to preserve the 'was's ;))

Bijan Parsia bparsia at email.unc.edu
Wed Jun 7 18:21:28 UTC 2000


On Wed, 7 Jun 2000, Florin X Mateoc wrote:

> The arithmetic "precedence" rules in Smalltalk are problematic not because they
> are conforming with a different paradigm,

So you agree with my correction? I was primarily challenging the
*argument* not the conclusion. Though I'd challange that as well (as I did
as a sideline).

> but because they are non-conforming
> with the very paradigm they are "supporting" - that is, sending messages 
> to the
> APPROPRIATE objects.

Huh? I never heard that. "sending messages to objects", is it, as far as
I'm concerned. :)

Appropriateness, in this case, seems interest relative and context
dependant.

>  Numbers are not the "natural" receivers for binary
> operators,

They aren't binary operators. They're binary messages. They're, except for
precedence, strictly equivalent to a keyword message with only one
keyword.

	2 + 2 ---> 5 "Damn SmallInteger bug :)"
	2 plus: 2 ---> 4 "Ah, fixed!"

A binary message has a single argument.

> ordered pairs are.

Lost me.

> So if we had #+ implemented (as a unary message from Smalltalk's 
> perspective)

I find it absolutely amazing that you didn't boggle at writing "as a
*unary* message from Smalltalk's perspective". Exactly. *Not* as a binary
message. The #+ in Smalltalk is *not* an operator. Of any kind. The binary
messages *do* have an operatorish feel, which actually is rather useful
for conciseness.

> in
> Array (just an example), there would be at least consistency 
> (with both math and
> OO) in parsing

> (Array with: #(4 5) + with: 6) *

Er...er...er...

Uhm...

Forgive me, the boggle quotient was way too high.

> Even for beginners, I think consistency provides greater benefits than the
> currently implemented "friendlier" approach.

Consistency with *what*? I frankly find the above horrific and would
rather program C++ (not just Java! C++!) than fight that.

Whatever it's consistent with, I don't wish to be :)

The current way is consistent with two things:

	1) Ordinary English "on the fly" computation.
	2) Smalltalks message passing paradigm.

As such it uses the "familiar" (for non-heathen english speakers who are
like me) as a bridge to the "unfamiliar", in a way that isn't horribly
cumbersome. As such, it walks a fine line.

It is *inconsistent* with many things, among which there is:

	1) Algol style mixfix.
	2) Lisp, Prolog, or Forth prefix/postfix
	3) High School Algebra (somewhat like 1)
	4) That ordered pair thingy.

The last certain is novel. It doesn't worry me at all :)

1 and 3 is what people usually cite, but I find it *useful* to be
inconsisten with those for three reasons:

	1) The one I mentioned above, about getting into message passing.
	2) It makes me notice the arbitrariness of Algolish precedence and
	   realize that I don't have to cope with it in order to program.
	3) It reminds me that High School Algebra syntax is arbitrary and
	   not good for many purposes, and my hating in in 7-10th grade
	   was reasonably founded, and I should remember than instead
	   of merely accepting my forcible socialization.

Ok, there's a bit of a smilie on the last, but not totally. Scanning the
whole string which is the formula in order to make decisions about meaning
is a bit odd for left-to-right readers. Not completely, obviously. But
it's nice to recognize when we're internalized something, and it can be
liberating to take some distance from our filters.

Actually, this is one of the reasons I *love* Smalltalk. It *isn't* always
smooth, or perfectly elegant; there *are* parts that are clunky. But
there's so much *thought* in it, and so much that I learn and relearn in
my encounters with it.

It is in *this* sense that I think Smalltalk *is* a good language/system
for kids.

Cheers,
Bijan Parsia.
Profundity while you wait.





More information about the Squeak-dev mailing list