Path: utzoo!mnetor!uunet!husc6!ut-sally!im4u!milano!ghostwheel!ned From: ned@ghostwheel.UUCP (Ned Nowotny) Newsgroups: comp.lang.c Subject: Re: Power (Re: all those :-) Message-ID: <132@ghostwheel.UUCP> Date: 5 Feb 88 18:02:52 GMT References: <302@Aragorn.dde.uucp> <7139@brl-smoke.ARPA> <3461@ihlpf.ATT.COM> <3521@ihlpf.ATT.COM> <744@PT.CS.CMU.EDU> Reply-To: ned@ghostwheel.aca.mcc.com.UUCP (Ned Nowotny) Organization: MCC Database Program, Austin, Texas Lines: 42 In article <744@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes: >In article <3521@ihlpf.ATT.COM>, nevin1@ihlpf.ATT.COM (00704a-Liber) writes: >> >> Then where is the operator for string concatenation, and square root, and >> everything other binary function that is used by C programmers? > >Why not? why not have an extendable language, where the user is free to >define his own infix operators? Is it that outragous? >THIS IS JUST HYPOTHETICAL - I"M NOT SERIOUSLY APPROSING THIS! > In some sense, C++ has this (mis-)feature -- operator and function overloading. Conceptually, overloading is very nice. It allows programmers to declare new data types and operations on them using standard notations. For instance, a complex double data type can be defined and then operations can be defined on these data types using the "+", "-", etc. operators. Unfortunately, not all programmers seem to agree on what constitutes a good use of operator overloading. I have seen code which overloaded "+" and "-" to add and remove, respectively, an object from a set of objects. The result was an unforeseen side effect to some global data structure using these operators on the given data type and code similar to the following: do_something(); A + B; do_something_else(); That's right. It looks like a useless expression, but its not. Its just a headache for the next programmer. Function overloading can result in similar, but less painful abuses. Of course, it can be argued that the misuse of a feature by a programmer is no excuse for blaming the feature. However, functional notation is perfectly adequate for programmer defined operations and somewhat easier to track down. Infix notation is better left to a language implementor. At least then, everyone who uses the language knows what a given expression means, even when it doesn't mean the right thing. -- Ned Nowotny (ned@ghostwheel.aca.mcc.com.UUCP)