Order of precedence

glenn krasner at objectshare.com
Tue Jan 26 17:38:32 UTC 1999


I'm an adult and I don't think that 3+4*5=23. I don't think necessarily
that 3+4*5=60 either.  I don't think adults use any particular precedence
order.

Sure, those adults or children who have been initially taught a particular
precedence order in certain programming languages seem to come with a
perferred "use", but they already have the concept of precedence in
computer languages. In fact, event they have learned the concept of
left-to-right (or right-to-left or some such) precendence order to handle
expressions such as 3-4-2. So all they need to deal with is going from two
rules to one. Smalltalk does not have a lack of precedence order for infix
operators, it just has a singe order, left-to-right.

So it seems to be the options are
	a) disallow multiple-infix operators
	b) set a single precedence rule, such as left-to-right
	c) cater to adults and children already computer-skilled who have
preconceived notions set by some other computer languages which have
multiple rules, one operator-based and the other left-to-right (or
right-to-left or some such).

I still think Smalltalk's choice of b) is best and works for children and
adults.

glenn

At 02:53 PM 1/25/99 -0500, Ian Bicking wrote:
>I was thinking a bit on something talked about a while before -- that Squeak
>should support the child up to the adult.  I think Squeak is doing a good
>job of supporting the adult, but what about the child?
>
>One of the problems I see of using Squeak with children is the lack of order
>of precedence.  The problem is that introducing Squeak to a child would be a
>bit dangerous in this regard.  Order of precedence is *not* intuitive --
>quite the contrary, Smalltalk *is* intuitive in this regard.  In this way,
>Squeak would reinforce exactly the wrong notions for the child.
>
>Modern math curriculums seem to be quite careful about avoiding strings of
>operations without using explicit order of precedence (lots of parenthesis)
>until the later grades.  Unfortunately (or fortunately) a computer language
>can't do that because a child can explore the language and discover
>precedence (or lack thereof) on their own.
>
>Of course, the parser could be adapted fairly easy to create a special view
>of Squeak where precedence existed.  But I think it would be nice if
>children really could use exactly the same language and syntax that adults
>use.
>
>So, can we (should we) make Squeak believe 3+4*5=23 ?
>
>
>               -- Ian Bicking
>
>
>





More information about the Squeak-dev mailing list