From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public From: Alan Lovejoy Subject: Re: OO, C++, and something much better! Date: 1997/02/07 Message-ID: <32FB8B51.1759@concentric.net>#1/1 X-Deja-AN: 215146654 references: <5de62l$f13$1@goanna.cs.rmit.edu.au> content-type: text/plain; charset=us-ascii organization: Modulation mime-version: 1.0 reply-to: alovejoy@concentric.net newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object x-mailer: Mozilla 3.01Gold (Win95; I) Date: 1997-02-07T00:00:00+00:00 List-Id: Richard A. O'Keefe wrote: > > I wrote: > : The type system is not the only way in which Smalltalk differs from C. > : Another important way is the syntax of function calls. > : Smalltalk encourages the use of infix operators whenever it makes sense. > > "John W. Sarkela" writes: > >On the contrary, Smalltalk does not encourage the use of > >operators whatsoever. There are two and only two operators > >in Smalltalk. > > I think any fair person would agree that calling "+" an operator is > not _wholly_ unreasonable, even in Smalltalk. The _application_ of > "+" to arguments is a message send, but "message send" is no more and > no less than "dispatched procedure call". > > Anyone saying that "+" is not an operator in Ada, for example, on the > flimsy grounds that "+" is actually an overloaded function, would not > be taken seriously. (Except in APL) "operator" is a syntactic property, > not a semantic one. An "operator" is a "built in" function whose semantics is defined by the grammar of the language. The "name" of an operator is usually either reserved, or else would not be a syntactically valid programmer-defined function identifier. In languages that permit "operator overloading," there will be syntactic (and usually semantic) constraints on the definition of an "operator" that would not apply to other functions. For example, the name of an operator would have to be the same as one of the "built in" operators. A programmer-defined operator named "=" would probably be constrained to have a Boolean return type, and to have only two arguments. The "+" operator would be constrained to have only two arguments, and would have a predefined and unchangeable evaluation order precedence. The reason that "+" would be considered an operator in languages that have "operator overloading" is because the semantics of "+" is (partially) defined by the syntax of the language. One does not need to define the meaning of "+" in Ada (as a function with source code) in order to use it for integer addition. In Smalltalk, "+" has no formal meaning **syntactically** other than "a message whose selector is +". There is a method (with editable source code) that defines the meaning of "+" for Integers (actually, there are three, one for SmallIntegers, one for LargeIntegers, and an abstract one for Integers that aren't Small or Large (any such would have to be defined by the programmer). However, most Smalltalk implementations optimize the "+" message. If this message is sent to a SmallInteger, the runtime system (usually a VM, but not always) does integer addition directly without actually doing a dynamic method dispatch. So one can simply remove the "+" method from SmallInteger, and nothing will break! So "+" is not formally an operator, but may be one in practice (in most implementations). But if it is an operator, it's not because it has the name "+", but because its meaning (in at least one case) is not defined by a construct (such as a method) expressed "in the language." -- Alan L. Lovejoy |==============================================| Smalltalk Consultant | Beware of Geeks bearing GIFs! | alovejoy@concentric.net |==============================================|