TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CLIFF RHODES
from: JERRY COFFIN
date: 1997-08-24 09:04:00
subject: ctors

On (23 Aug 97) Cliff Rhodes wrote to Frank Adam...
 --> Frank Adam wrote to Cliff Rhodes <--
 FA>to I've been thinking about this for a while, is there a technical
 FA>reason why constructors are not able to return a value ?
[ ... ]
 CR> Maybe Jerry knows the exact rationale?
AFAIK, there's virtually no way you could access a return value from a
ctor.  Basically, there are two ways to create objects - statically and
dynamically.  Given the following:
    someClass x;
    someClass *x = new someClass;
how would you manage to look at a return value from the ctor in either
case?
To manage this, you'd have to invent some _entirely_ new syntax and
semantics that don't bear even minimal resemblence to anything in C.
E.g. you could invent a method of returning two entirely separate things
from an assignment statement, with syntax something like:
    int status;
    someClass *object;
    status, object = new someClass;
with `object' being assigned the new object (if any) and status being
assigned the return value from the ctor.
However, you'd have to figure out a different method of dealing with
problems in statically allocated objects.  There's no question that a
method could be invented to allow seeing that as well, but I suspect by
the time it was finished, it'd bear little resemblence to C, and likely
wouldn't fit with the rest of the language very well.  Brooks pointed
out that the greatest strength of a good design is conceptual integrity,
and I agree completely; C++ has enough warts (primarily for backward
compatibility) and doesn't need more like this added.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.