In message Tue, 26 Jan 1999 09:38:32 -0800, glenn krasner@objectshare.com writes:
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'm not saying that the normal, mathematical rules of precedence are easier for children. Quite the contrary -- Smalltalk's simple left-to-right rule is much more intuitive. This is the problem. A child who is introduced to Smalltalk's system would likely have their intuition reinforced, making it all the harder to learn the proper (mathematical notation) rules of precedence.
The fact of the matter is, mathematics says that 3+4*5=23. You can't change that -- the mathematical conventions of the world are not going to be changed because they are easier for the computer to parse. In a practical matter, those conventions have been created because they *are* easier to parse (for humans) in real-world situations. They lead to less parenthesis. They group factors. They *are* aesthetic.
Perhaps the real answer is to have a view of Squeak where the syntax is fully mathematical. Where 3*sin(x^2+2) works. In this view a child could learn mathematics. But it seems that a better solution could be made, one that encompasses both needs (simplicity and conformity) instead of requiring a break-away syntax.
I bring this up because I've been looking at Logo, and one of the big compromises they made in the syntax was to allow infix notation even though it wasn't part of the Lisp tradition and sullied the syntax quite a bit.
Now, this is all assuming that a goal of Squeak (distinct from Smalltalk) is as a pedagogical tool. This is by no means necessarily true... though it would be neat if Squeak could be used by children, that doesn't mean it needs to be created for them to learn from it (though, of course, it is impossible to seperate use from learning). Pedagogically, introducing something that looks almost like proper mathematical expressions but isn't is a bad thing to do. This is one reason (not necessarily a huge reason) that I don't think Squeak is ready for children.
-- Ian Bicking
Ian Bicking wrote:
In message Tue, 26 Jan 1999 09:38:32 -0800, glenn krasner@objectshare.com writes:
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'm not saying that the normal, mathematical rules of precedence are easier for children. Quite the contrary -- Smalltalk's simple left-to-right rule is much more intuitive. This is the problem. A child who is introduced to Smalltalk's system would likely have their intuition reinforced, making it all the harder to learn the proper (mathematical notation) rules of precedence.
The fact of the matter is, mathematics says that 3+4*5=23. You can't change that -- the mathematical conventions of the world are not going to be changed because they are easier for the computer to parse. In a practical matter, those conventions have been created because they *are* easier to parse (for humans) in real-world situations. They lead to less parenthesis. They group factors. They *are* aesthetic.
Nobody seems to have pointed out that the binary operators are not just mathematical operators. The binary operators are in fact an arbitrary and extensible set of infix message selectors, some of which just happen to be used for some mathematical operators. e.g. there's no binary exponentiation operator in the original Smalltalk-80, one uses raisedTo:. e.g. @ constructs points and isn't a mathematical operator at all. So changing the precedence rules for infix operators would unnecessarily complicate the other, and equally valid, uses of these operators.
I've taught undergraduate and post-graduate courses in Smalltalk and have had students that liked and disliked the infix precedence rules. But I've never encountered a student that didn't get the rules pretty quickly. The left-to-right rule is so simple that even though one may not like it one can learn it really quickly.
Perhaps the real answer is to have a view of Squeak where the syntax is fully mathematical. Where 3*sin(x^2+2) works. In this view a child could learn mathematics. But it seems that a better solution could be made, one that encompasses both needs (simplicity and conformity) instead of requiring a break-away syntax.
So we're supposed to do without #==, #~~, #->, #@? And where does mathematics define commonly taught and understood precedence rules which include the relational operators? What are the relative precidences of + - * / \ // < <= > >= = ~= ? What's the scheme for defining the precedence of new operators a programmer might introduce? How can one ensure that different programmers use the same precedence order if they both introduce a new operator? Or is maintaining readability less important than attempting to provide an inaccurate simulation of mathematical notation (e.g. * instead of adjacency)?
I bring this up because I've been looking at Logo, and one of the big compromises they made in the syntax was to allow infix notation even though it wasn't part of the Lisp tradition and sullied the syntax quite a bit.
But Smalltalk's solution doesn't sully the syntax at all.
Now, this is all assuming that a goal of Squeak (distinct from Smalltalk) is as a pedagogical tool. This is by no means necessarily true... though it would be neat if Squeak could be used by children, that doesn't mean it needs to be created for them to learn from it (though, of course, it is impossible to seperate use from learning). Pedagogically, introducing something that looks almost like proper mathematical expressions but isn't is a bad thing to do. This is one reason (not necessarily a huge reason) that I don't think Squeak is ready for children.
I don't accept the argument that its good pedagogics to maintain an inaccurate and partial simulation of common mathematical notation. I do accept the argument that its good pedagogics to use simple but adequately powerful rules. I think very strongly that the current design of the infix rules is better than any other programming language I've used, that its easier to teach, that its easier to learn, and easier to use.
_______________,,,^..^,,,_______________ Eliot Miranda, ParcPlace
Eliot & Linda Miranda wrote:
Ian Bicking wrote:
In message Tue, 26 Jan 1999 09:38:32 -0800, glenn krasner@objectshare.com writes:
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'm not saying that the normal, mathematical rules of precedence are easier for children. Quite the contrary -- Smalltalk's simple left-to-right rule is much more intuitive. This is the problem. A child who is introduced to Smalltalk's system would likely have their intuition reinforced, making it all the harder to learn the proper (mathematical notation) rules of precedence.
The fact of the matter is, mathematics says that 3+4*5=23. You can't change that -- the mathematical conventions of the world are not going to be changed because they are easier for the computer to parse. In a practical matter, those conventions have been created because they *are* easier to parse (for humans) in real-world situations. They lead to less parenthesis. They group factors. They *are* aesthetic.
Mathematics does not say that 3 + 4 * 5 = 23. I have never seen any mathematic text refer to multiplication using the asterix character. I have watched this thread here and in c.l.s. for a while now. I am some what of a sci/math/eng type. I've been doing ST in eng apps for going on 9 years. I used to work in the Nuclear industry where the equations or so hairy that reading them will put hair on your chest. My degree is in Mechanical Engineering. I did alot of math in high school. And so I went back and looked at some of my high school and M.E. homework. I cannot find a single instance where I wrote out statement that depended on the ol' "multiply first" rule, though I like other's learned this rule early on in life. I've got a slew of my M.E. and C.S. college texts sitting around me and have spent the last half hour looking at them trying to find one instance where application of this rule would dissambiguate a situation. I can't. The truth, I have yet to find a case where the cross product symbol (the grade school multiply operator) is used at all. I have hardly even found any dot notations. Most multiplications are just implied by adjacent neighborship. Basically, the only rule I can see that applies is that you combine symbols that are spatially closest to each other. Having worked with FORTRAN codes that model nuclear thermodynamics and nuclear kinetics down to the cubic centimeter, I never came across an instance where the FORTRAN rules or precedence weren't reinforced by grouping terms. It was considered bad style to employ the mathematic rules. Interesting statement huh? Here you have these rules in a language for your benefit, and no one wants to use them, because it makes the code harder to read. In short, I'm really struggling to see the value that would be gained from coming up with some sort of scheme that would apply the "multiply first" rule. Exist it might, I consider the rule of no value, since I'm not finding any real world examples of its use.
-- Travis Griggs (a.k.a. Lord of the Fries) Key Technology tgriggs@keyww.com Member, Fraven Skreiggs Software Collective - C for Sinking - Java for Drinking - Smalltalk for Thinking ...and Power to the Penguin!
Eliot & Linda Miranda wrote:
So we're supposed to do without #==, #~~, #->, #@?
Of course not. A system that doesn't allow the definition of new operators (as shortcuts for the *very* common operations) isn't going to be very useful, so this is just a straw argument.
And where does mathematics define commonly taught and understood precedence rules which include the relational operators?
Relational operators generally have a lower precedence than arithmetic. This is because these aren't considered operators in general math, but delimiters in equations (resp. inquations).
What are the relative recidences of + - * / \ // < <= > >= = ~= ?
From my above remarks, a highest-to-lowest precedence table is actually
easy to construct, and actually observed in multi-precedence languages like C and Prolog:
Exponentiation ^ (is this actually in Smalltalk?) Multiplicative * / // \ Relational < <= > >= Equality = == ~ ~~ Assignment :=
Exponentiation should be right-associative (following mathematical tradition), all others are left-associative. The separation of relational and equality operators on different precedence levels is actually not mathematical tradition, but programming tradition (since Algol 60 I think).
What's the scheme for defining the precedence of new operators a programmer might introduce?
There are two sensible positions: between Equality and Assignment (so that they are always evaluated last), or between Multiplicative and Equality (so you can compare results from user-defined operators). One could also consider them to be highest priority, but I don't feel one should do that (it's just an intuition, I couldn't list reasons, except that I don't know of any language that makes them highest-priority).
How can one ensure that different programmers use the same precedence order if they both introduce a new operator?
Operators from different authors cannot really combine (and usually don't anyway), so it isn't too harsh to declare them non-associative. This means that the parser insists on parentheses to disambiguate expressions like 2 @ 3 @ 4, or 2 -> 3 @ 4.
Or is maintaining readability less important than attempting to provide an inaccurate simulation of mathematical notation (e.g. * instead of adjacency)?
Bah. No rethorics please. I understand you are accustomed to Smalltalk tradition and don't want to learn new tricks for little gain, but that doesn't necessarily mean that the position of anybody with a different opinion is so ridiculous as you present it here.
I don't accept the argument that its good pedagogics to maintain an inaccurate and partial simulation of common mathematical notation. I do accept the argument that its good pedagogics to use simple but adequately powerful rules.
There is no such thing as "mathematical notation" anyway. The notation varies wildly across branches of mathematics. However, pedagogically, there is no point to pretend there are no precedence rules. There are. When I learned Smalltalk, I had some (admittedly minor) difficulties to adjust to the no-precedence rule.
I think very strongly that the current design of the infix rules is better than any other programming language I've used, that its easier to teach, that its easier to learn, and easier to use.
I think that's entirely subjective. I'd go so far to agree that your point of view is reasonable, but I hope you can agree that mine is reasonable as well.
However, I think the real reason for not having precedence rules in Smalltalk isn't "quality" (in whatever sense), teachability, ease of learing, or ease of use. It is just that precedence rules would double the amount of syntax rules for Smalltalk. In a more conventional language, precedence is a negligible part of the total syntax and the Right Thing to have; in Smalltalk, it would just take up a nonproportional amount of attention, so it is reasonable to not have it.
Regards, Joachim
squeak-dev@lists.squeakfoundation.org