On 17 Mar 2004 at 20:08, Frank Heckenbach wrote:
Neil Santos wrote:
[...]
And, oh, is there any way to turn a constructor into a function? :P
You can use any constructor as a Boolean function. It will return False if the constructor calls Fail, otherwise True. Is that what you mean?
I suspect that what he is referring to is the Delphi class syntax whereby a constructor returns a pointer to the object - e.g., myobj := tMyObj.MyConstructor;
So perhaps whatever magic is responsible for being able to use a constructor as a boolean function may possibly be also used for enabling the use of constructors to return a pointer to the object. I would also find such a thing useful. It would involve some implicit things - e.g.,
Constructor TMyobj.Create; begin blah; blue; blih; end;
would become something like this; Constructor TMyobj.Create; begin New (Result); { implicit "New"; I guess that the "Result" here would be "Self" in Delphi classes } With Result^ do begin { implicit "With" (in Delphi = "With Self"?) } blah; blue; blih; end; end;
I am not sure how feasible (or even desirable) it is to do something like this (especially if not also going thereby down the full Delphi "class" route). Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/