Page 3 of 3 FirstFirst 123
Results 21 to 29 of 29

Thread: Matrix unit

  1. #21

    Matrix unit

    Quote Originally Posted by dmantione
    Do you think there is a way to do the same with the new Delphi overloaded operators? If yes we could consider to write a Delphi unit that results in the same syntax for users of the library.
    I don't know, didn't use Delphi to do anything serious since a long time... Any links to Delphi operator overloading syntax ?

  2. #22

    Matrix unit

    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>

  3. #23

    Matrix unit

    Quote Originally Posted by technomage
    This is straight out of the BDS 2006 Manual. I think this is different to the way free pascal does it.... :?:
    Yeah, definitely different... So in Delphi operator overloading may be done only for classes ? No way do to it for old-style objects ?

  4. #24

    Matrix unit

    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?

  5. #25

    Matrix unit

    Quote Originally Posted by michalis
    Yeah, definitely different... So in Delphi operator overloading may be done only for classes ? No way do to it for old-style objects ?
    Borland Have depreciated the myclass = object , this has been the case since delphi 3 (I think) , it's something they supported for old applications.
    <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>

  6. #26

    Matrix unit

    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

  7. #27

    Matrix unit

    Quote Originally Posted by JSoftware
    just use it with records in delphi. BDS supports functions inside records and even supports operator overloading for records
    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.

    The old object model (1990 or thereabouts) already was like that + that it supported virtual methods.

  8. #28

    Matrix unit

    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.

  9. #29

    Matrix unit

    It took a while, but nowadays one can use properties in objects. (Since 2.0.0 as far as I know.)

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •