[fpc-devel] Re: [fpc-l] type discussion

Jamie McCracken jamie-junk at blueyonder.co.uk
Thu Jun 2 23:44:35 CEST 2005


Daniël Mantione wrote:
> 
> Op Thu, 2 Jun 2005, schreef Jamie McCracken:
> 
> 
>>Daniël Mantione wrote:

> 
> 
> Ok! We'll be happy to assist anyone doing interresting developments with
> Free Pascal. Keep in mind though that implementing ideas can take "a lot"
> more time that thinking out ideas.
> 
> The Free Pascal parser is indeed manual craftmanship. Some experimenting
> was done using yacc in the past but a handwritten parser turned out to be
> the best choice. The parser units start with the letter p, for example
> pexpr.pas is the expression parser.

You've done it the hard way - no wonder developer's are reluctant to 
implement syntax changes!


> Yes... Because Java often turns out to be the wrong tool and its memory
> management is one of the reasons. We need to be carefull to prevent Pascal
> becoming a wrong tool. However, automated memory management does have some
> advantages. Nobody can deny that.

Ref counting does not use more memory! (well okay 32 bits extra to store 
the ref count for each object).

>>except were the source is bloated by forward declarations :)
> 
> 
> Just order your procedures like you should order them, go go!! :)
> 
> daniel at laptop:~/fpc2/fpc/compiler> grep ';forward;' *.pas
> browlog.pas:    procedure writesymtable(p:Tsymtable);forward;
> pexpr.pas:    function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):tnode;forward;
> pstatmnt.pas:    function statement : tnode;forward;
> daniel at laptop:~/fpc2/fpc/compiler> grep '; forward;' *.pas
> browcol.pas:  function GetDefinitionStr(def: tdef): string; forward;
> scanner.pas:        function read_expr : string; forward;
> daniel at laptop:~/fpc2/fpc/compiler>
> 
> Wow! 5 forward declarations in the entire compiler source. Yeah, bloat
> indeed.... :)
> 
>

its a bit more than that. Forward declarations include the class 
interfaces too in the type section. EG under delphi :


uses
   Classes, SysUtils;

type

   TMyObject = class (Tobject)
   private
       count : integer;	
   public
       constructor create; override;
       destructor destroy; override;	
   end;

implementation

constructor TConfigureBuildLazarusDlg.Create(AnOwner: TComponent);
begin
   inherited Create(AnOwner);
   inc (count);	
end;

destructor TConfigureBuildLazarusDlg.Destroy;
begin
   inherited Destroy;
end;

end.



would become under Rad Pascal:

uses
   Classes, SysUtils;

  TMyObject = class (Tobject)
     private
         count : integer;	
     public
         constructor create; override;
	    inherited Create(AnOwner);
	    inc (count);
	
         destructor destroy; override;	
	    inherited Destroy;


Notice its at least 50% less code to write.


jamie.




More information about the fpc-devel mailing list