home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!utcsri!torn!news.ccs.queensu.ca!mast.queensu.ca!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: BP/TP OOP is missing something...
- Message-ID: <dmurdoch.282.722020256@mast.queensu.ca>
- Lines: 39
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <KIM.92Nov16125141@kim.Software.Mitel.COM> <1992Nov17.153804.21729@news.clarkson.edu>
- Date: Tue, 17 Nov 1992 17:10:56 GMT
-
- In article <1992Nov17.153804.21729@news.clarkson.edu> kooijman@sun.soe.clarkson.edu (Harry Kooijman,Peyt314a,3808) writes:
- >Why is it that TP with objects does not have the capability to call the
- >constructors when variables are declared? And when an object goes out of
- >scope it should be destructed automatically. For example:
- >
- >Function DoSomethingWithD;
- >Var D:DoubleObject(1.2);
- >Begin
- > ...
- > Do something with D
- > ...
- >End; {and here D gets destructed}
-
- This is there in TP, to a very limited extent: you can have an initialized
- variable which is an object, and you needn't call the constructor. It's
- initialized at program load time, not each time the variable comes into
- scope. The destructor is never called.
-
- I think the main reason that TP doesn't have automatic constructor/
- destructor calls is because it is descended from Pascal. In Pascal in
- general, code doesn't get executed unless you explicitly ask for it.
- Adding automatic code would be a big change to the flavour of the language.
-
- It's pretty unlikely that Borland would make such a fundamental change
- that doesn't add any power to the language. Your code fragment is exactly
- equivalent to
-
- var D:DoubleObject;
- begin
- D.init(1.2);
- ...
- D.done;
- end;
-
- Since what you want to do is already possible with nothing more than a
- couple of extra lines of code, why make a big change to the language?
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-