Re: gdb-patches RFA: Fix pascal behavior for class fields

"Prof Abimbola Olowofoyeku" <[email protected]>
Newsgroups gmane.comp.compilers.gpc
Organization ChiefSoft
Message-ID <[email protected]>
On 8 Jan 2015 at 23:12, Pierre Muller wrote:

> For gpc mailing list:
[...]
> 
>   The problem is that GPC and Free Pascal support several
> 
> pascal 'dialects'. But this requires command line options.
> 
> 
> 
>   The -Mobjfpc option is required for Free Pascal compiler
> 
> to understand class type definition, but is rejected in default mode.
> 
> 
> 
>   I expect GNU GPC to also reject class in 'normal' mode...
> 
> Maybe someone on the gpc mailing list knows if classes are supported
> 
> by GPC and if it requires a special compiler option.
> 
> 
> 
> Pierre Muller
> 
> 
> 
> FYI: Here is the example code that is included in the bug report.
> 
> 
> 
> $ cat ~/pas/test/test-class-pascal.pas
> 
> 
> 
> type
> 
>   TA = class
> 
>   public
> 
>   x, y : integer;
> 
>   constructor Create;
> 
>   function check(b : TA) : boolean;
> 
>   destructor Done; virtual;
> 
> end;
> 
> 
> 
> constructor TA.Create;
> 
> begin
> 
>   x:=-1;
> 
>   y:=-1;
> 
> end;
> 
> 
> 
> destructor TA.Done;
> 
> begin
> 
> end;
> 
> 
> 
> function TA.check (b : TA) : boolean;
> 
> begin
> 
>   check:=(x < b.x);
> 
> end;
> 
> 
> 
> 
> 
> 
> 
> var
> 
>   a, b : TA;
> 
> 
> 
> begin
> 
>   a:=TA.Create;
> 
>   b:=TA.Create;
> 
>   a.x := 67;
> 
>   a.y := 33;
> 
>   a.check (b);
> 
> end.

Supply "--extended-syntax" and GPC will accept "class" (and if you are 
going to use "Result" then you will need to add "--implicit-result"). 

However, I do not believe that the "class" will be treated much 
differently from a bog-standard Borland Pascal "object" - for example, 
not having (or not calling) a constructor will not crash the program 
(as it should do, with Delphi-style classes).

Best regards, The Chief
--------
Prof. Abimbola A. Olowofoyeku (The African Chief) 
web:  http://www.greatchief.plus.com/


_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.