Xref: utzoo comp.std.c++:285 comp.lang.c++:9376 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!emory!att!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Using return datum type in function signature Summary: Ada, yes. C++, no. Keywords: c++,signature Message-ID: <431@mole-end.UUCP> Date: 3 Sep 90 04:04:30 GMT References: <4335@celery34.UUCP> Distribution: comp Organization: mole-end--private system. admin: mole-end!newtnews Lines: 42 In article <4335@celery34.UUCP>, stephens@motcid.UUCP (Kurt Stephens) writes: > Why isn't the return datum type used in the construction of > a function signature? Would it be helpful to have overloaded > with the same argument signatures but different return types? . . . > Is this impossible because the call to Get() can only > be disambiguated by examining the surrounding context? You've hit upon it, more or less. In many languages (Ada included) the context can be used to help in disambiguation. C's very flexible expression syntax and semantics are such that, were C++ to allow such disambiguation, the rules that would have to be applied would prevent `ordinary' C things from working correctly. For example, if you have a pair of overloads disambiguated only by their return values (say an int s() and an X s() ) and you call the function at the top level of an expression statement, i.e. as { s(); } how do you disambiguate? Even if you argue that you are converting the return values to void , on the basis of what could you prefer one conversion to void over another? In other languages, expressions are tightly constrained things; in C and C++, they are the world. There is an almost LISPis quality about them, and that means that there are things you cannot do. It should be noted that it took several months and a number of papers in various journals before the computing community solidly established that there is a usable algorithm for Ada-style disambiguation. It may take four passes over the expression tree before everything is fully disambiguated. -- (This man's opinions are his own.) From mole-end Mark Terribile