I don't know, didn't use Delphi to do anything serious since a long time... Any links to Delphi operator overloading syntax ?Originally Posted by dmantione
I don't know, didn't use Delphi to do anything serious since a long time... Any links to Delphi operator overloading syntax ?Originally Posted by dmantione
Operator overloading is done using what I would call Operator Mapping. The following example the compiler "maps" + operator to the Add Method.
[pascal]
TMyClass = class
class operator Add(a, b: TMyClass): TMyClass;
end;
[/pascal]
[pascal]
var a,b : TMyClass;
begin
a + b; // Calls TMyClass.Add(a, b: TMyClass): TMyClass
end;
[/pascal]
This is straight out of the BDS 2006 Manual. I think this is different to the way free pascal does it.... :?:
<A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
<br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
<br /></A>
Yeah, definitely different... So in Delphi operator overloading may be done only for classes ? No way do to it for old-style objects ?Originally Posted by technomage
Well, the main reason to do objects is that they don't need to reside on the heap, which means temp matrices are in the fast stack. Using classes results in memory management issues, i.e.
a:=b*c+d;
.. results, depending on compiler smartness, in one or two intermediate matrices. How does BDS solve this in native mode?
Borland Have depreciated the myclass = object , this has been the case since delphi 3 (I think) , it's something they supported for old applications.Originally Posted by michalis
<A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
<br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
<br /></A>
just use it with records in delphi. BDS supports functions inside records and even supports operator overloading for records
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
That's a useless .NET copycat feature; They had it for .NET, and enabled it for D2006 at the same cost (afaik BDS2005 doesn't support it?), but without any merit.Originally Posted by JSoftware
The old object model (1990 or thereabouts) already was like that + that it supported virtual methods.
Using objects here is perfectly sane since objects are very fast compared to classes, and you might want to have a memory-free experience with matrices.
Strictly speaking, apart from properties (afaik) and metaclasses, there's very little classes offer which is worth the extra performance loss and inability to use them on stack.
Feel the power of Open Source.
<br />Feel the power of Free Pascal.
It took a while, but nowadays one can use properties in objects. (Since 2.0.0 as far as I know.)
Bookmarks