Re: [fpc-pascal] Problems with generics

2007-12-30 Thread bartek
On Sunday 30 December 2007 07:32:22 Micha Nelissen wrote:
> bartek wrote:
> > function HashOf(const Key: ShortString): DWord;
> > 
> > function BucketNodeOf(const Hash: DWord): TBucket.PNode;
> > DataContainers.pp(104,66) Fatal: Syntax error, ";" expected but "." found
> 
> I'd say this is a bug, and your syntax is correct. Update the existing
> bug report, perhaps?
> 
> Micha
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

I am not quite sure whether my synatx is correct. IMHO explictly defining the 
type feels more pascalish. Having more time at hand i have written a much 
shorter example code which shows in what way such a type should be defined.

Now I get:

[1004] [EMAIL PROTECTED]:~/Dev/Tests
% fpc test3.pp
Free Pascal Compiler version 2.3.1 [2007/12/28] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling test3.pp
test3.pp(18,32) Error: Error in type definition
test3.pp(26,34) Error: Type "TPT" is not completely defined
test3.pp(47,18) Error: Identifier not found "TPT"
test3.pp(49,24) Error: Identifier not found "Data"
test3.pp(54) Fatal: There were 4 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not 
specify a source file to be compiled)

"Error in a type definition". I do not know whether fpc is supposed to support 
this kind if structures. If it is than it is a bug otherwise, no.

Code:

{$mode objfpc}{$h+}
program test3;
uses classes, sysutils;
type
generic TNode = class
type public
PT = ^T;
var private
Data: T;
public
constructor Create;
destructor Destroy; override;
end;

generic TContainer = class
type public
TTNode = specialize TNode;
TPT = TTNode.PT;
var
private
Data: TTNode;
public
constructor Create;
destructor Destroy; override;

function Get: TPT;
end;

constructor TNode.Create;
begin
end;

destructor TNode.Destroy;
begin
inherited Destroy;
end;

constructor TContainer.Create;
begin
end;

destructor TContainer.Destroy;
begin
inherited Destroy;
end;

function Get: TPT;
begin
result := @Data.Data;
end;

begin
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with generics

2007-12-30 Thread Micha Nelissen
bartek wrote:
> I am not quite sure whether my synatx is correct. IMHO explictly defining the 
> type feels more pascalish. Having more time at hand i have written a much 
> shorter example code which shows in what way such a type should be defined.

I think that it is the same type in a different namespace. Like using
"unit.type" syntax.

Micha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with generics

2007-12-30 Thread bartek
On Sunday 30 December 2007 15:31:32 Micha Nelissen wrote:
> bartek wrote:
> > I am not quite sure whether my synatx is correct. IMHO explictly defining 
the 
> > type feels more pascalish. Having more time at hand i have written a much 
> > shorter example code which shows in what way such a type should be 
defined.
> 
> I think that it is the same type in a different namespace. Like using
> "unit.type" syntax.
> 
> Micha
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

Yes you are right, I did not think of that. I think a seperate bugreport is 
appropriate, since this bug is not even really related to the previous bug.
The last one made the 2.2.0 compiler crash, this one is a missing feature in 
the svn trunk.

Reported as #0010512 with unit.type/(generic)class.type as expected behaviour.

bartek
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal