TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: FRANK ADAM
from: JERRY COFFIN
date: 1997-09-02 09:52:00
subject: ctors

On (28 Aug 97) Frank Adam wrote to Jerry Coffin...
 JC> To manage this, you'd have to invent some _entirely_ new syntax
 JC> and semantics that don't bear even minimal resemblence to anything
 JC> in C.
 FA> I believe it should've been done. After all C++ is not C and classes
 FA> are unique to the former. It's very possible that by default a class
 FA> may be initialized similarly to a structure,but once a user defined
 FA> ctor is used it becomes a definite (be it implicit) function call.
It's true that classes are unique to C++.  However, they're conceptually
quite closely related to structs in C.  In fact, the only fundamental
difference is that C says you can't put a function in a struct.  C++
simply eliminates that restriction.  In C++, `class' is simply an alias
for: `struct { private:' -- i.e. it declares a struct in which members
are private by default.
 FA> IMHO, all of a sudden the syntax 
 FA> just disallowed the checking of a return value from a function.
The syntax `void funcname()' did that in C a long time ago. 
Much like a function declared to return void, a ctor simply doesn't HAVE
a return value, so nothing ever disallowed checking the return value.
 JC> E.g. you could invent a method of returning two entirely separate 
 JC>     int status;
 JC>     someClass *object;
 JC>     status, object = new someClass;
 FA> Or could've been..
 FA> int status;
 FA> someClass *object;
 FA> object = new someClass(&status);
 FA> someClass x(&status);
 FA> Of course there would be no "no arg" constructors.
And there'd be no way to use this in conversion ctors, etc. either.
The ultimate goal for classes in C++ was/is the ability to create a type
that can be used similarly to a type built into the language.  While I
wouldn't say this was realized completely, I don't think the methods
eitehr you or I suggested allow that to nearly the degree that exception
handling does.
 FA> Anyway i was just thinking aloud, i don't think compiler vendors upon 
 FA> reading this, would rush off to change the language just for me.:-)
Improvements are rarely finished the minute somebody first starts to
discuss them.  I'm not _at_ _all_ averse to discussing things just
becaue they're not finished and polished.  As I point out above, I don't
think either you or I have come up with a method that's currently
superior to exception handling.  However, that doesn't mean that such a
thing might not exist.  Even if you or I decide it really doesn't exist,
the discussion leading to that conclusion might well be valuable anyway.
    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™.