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

Thread: Advantages of learning Pascal?

  1. #21
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Advantages of learning Pascal?

    I think the better question is usually which compiler is better than which language is better. Especially since the language isn't squat without a good compiler that has implemented it.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #22

    Advantages of learning Pascal?

    Quote Originally Posted by Almindor
    Quote Originally Posted by User137
    ...
    operator +(v1, v2: TVector2d): TVector2d;
    begin
    Result.x := v1.x + v2.x;
    Result.y := v1.y + v2.y;
    end;
    ...
    This work ?
    You can tell me more about it ?
    From brazil (:

    Pascal pownz!

  3. #23

    Advantages of learning Pascal?

    Quote Originally Posted by arthurprs
    Quote Originally Posted by Almindor
    Quote Originally Posted by User137
    ...
    operator +(v1, v2: TVector2d): TVector2d;
    begin
    Result.x := v1.x + v2.x;
    Result.y := v1.y + v2.y;
    end;
    ...
    This work ?
    You can tell me more about it ?
    I don't think it would work in FPC IIRC.
    This would afaik:
    [pascal]
    operator +(v1, v2: TVector2d) result: TVector2d;
    begin
    Result.x := v1.x + v2.x;
    Result.y := v1.y + v2.y;
    end;
    [/pascal]

    If you want it to compile and work in both fpc and turbodelphi then use the following:
    {$IFDEF FPC}
    operator +(v1, v2: TVector2d) result: TVector2d;
    {$ELSE}
    class operator TVector2d.add(v1, v2: TVector2d): TVector2d;
    {$ENDIF}
    begin

    end;
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  4. #24

    Advantages of learning Pascal?

    Quote Originally Posted by JSoftware
    Quote Originally Posted by arthurprs
    Quote Originally Posted by Almindor
    Quote Originally Posted by User137
    ...
    operator +(v1, v2: TVector2d): TVector2d;
    begin
    Result.x := v1.x + v2.x;
    Result.y := v1.y + v2.y;
    end;
    ...
    This work ?
    You can tell me more about it ?
    I don't think it would work in FPC IIRC.
    This would afaik:
    [pascal]
    operator +(v1, v2: TVector2d) result: TVector2d;
    begin
    Result.x := v1.x + v2.x;
    Result.y := v1.y + v2.y;
    end;
    [/pascal]

    If you want it to compile and work in both fpc and turbodelphi then use the following:
    {$IFDEF FPC}
    operator +(v1, v2: TVector2d) result: TVector2d;
    {$ELSE}
    class operator TVector2d.add(v1, v2: TVector2d): TVector2d;
    {$ENDIF}
    begin

    end;
    I tried several ways to make it work,
    please explain how make it with a Tpoint on Delphi

    PS: i use BDS2006
    From brazil (:

    Pascal pownz!

  5. #25

    Advantages of learning Pascal?

    Arthur, that code is for FPC. But this might be IDE independent:
    Code:
    {$IFDEF FPC}
    operator +(v1, v2: TVector2d) result: TVector2d;
    {$ELSE}
    class operator TVector2d.add(v1, v2: TVector2d): TVector2d;
    {$IFEND} 
    begin
      Result.x := v1.x  + v2.x;
      Result.y := v1.y + v2.y;
    end;
    In the same case you can just rename it to TPoint instead if you want to.

  6. #26
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Advantages of learning Pascal?

    Sadly, I think we got away from your question Chris. :?

    But to help directly answer what you may want to know...

    Proper programming structure and practices is a key feature of the language and a mainstay of all Pascal debuggers. At least those that are made to proper standards.

    C and C++ allows you to stray (sometimes too far) from the path that you should take while writing your code.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  7. #27

    Advantages of learning Pascal?

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TForm1 = class(TForm)
      private
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    
    implementation
    
    
    {$R *.dfm}
    
    class operator Tpoint.add(v1, v2: Tpoint): Tpoint;
    begin
      Result.x := v1.x  + v2.x;
      Result.y := v1.y + v2.y;
    end;
    
    end.
    This don't compile ;/
    From brazil (:

    Pascal pownz!

  8. #28

    Advantages of learning Pascal?

    Quote Originally Posted by arthurprs
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TPoint2d = record
       x,y: integer;
       class operator Add(v1,v2: TPoint2d): TPoint2d;
      end;
    
      TForm1 = class(TForm)
      private
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    
    implementation
    
    
    {$R *.dfm}
    
    class operator Tpoint2d.add(v1, v2: Tpoint2d): Tpoint2d;
    begin
      Result.x := v1.x  + v2.x;
      Result.y := v1.y + v2.y;
    end;
    
    end.
    This don't compile ;/
    This should compile

    If you are interested in OO(the delphi way) I have written a little article(in danish) with small bits of code here:

    http://udvikleren.dk/Delphi/Article.aspx/297/
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

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
  •