Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!iwtqg.att.COM!nowlin From: nowlin@iwtqg.att.COM Newsgroups: comp.lang.icon Subject: RE: Icon Ideas? (operators) Message-ID: Date: 27 Mar 90 05:15:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 53 > In response to a response to my posting,.... > > > > But back to the $. > > > > > > I wonder about the use of the $ to create user define operators. > > > > Wouldn't general operator overloading in Icon be better? > > Yes, I gave some thought to overloading some of the existing Icon operators. > > ... > > My icon background gives me the philosophy of typed operators as well as > (loosely) typed data/procedures. It seems more natural to keep the user > defined objects (operators, procedures, variables) separated from the built > in ones. This is only my opinion, and it may not line up with the goals > of the Icon project in the long run. > > Chris Tenaglia (System Manager) I can't remember if Bill's object oriented Icon has operator and function overloading or not. This is my two cents worth and if I've got it all wrong I trust someone will let me know. The language that has overloaded operators that I'm most familiar with is C++. It discriminates between overloaded operators (functions) by enforcing strict typing of operands (arguments). This is how the compiler determines which operation to perform on the operands. Operators can appear to take on almost any type for the programmer working with well defined C++ classes. Icon, on the other hand, has operands or variables that can be any type. To discriminate between different types of operands Icon uses fairly strongly typed operators (and functions). There are exceptions (assignment) but for the most part the operators in Icon are type specific. I know this because of all the run time errors I generate. You get a great deal of automatic type conversion in Icon but it's driven by the operators more than the types of the operands. You can add two strings of digits in Icon with the "+" operator but you get a numeric result, not a longer string of digits. You can also concatenate two numbers into a string of digits with the "||" operator. To allow overloaded operators would violate this scheme. How would Icon know whether to do automatic type conversion or try for another version of the operator that was a better fit to the given operands? Someone with experience in the implementation could shed more light on this. User defined operators that are distinguished from built-in operators by an explicit syntax are the best compromise but there are an awful lot of operators in Icon already. Procedure names can be very descriptive. (hint) Jerry Nowlin (...!att!iwtqg!nowlin)