Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-05

dtm_maker project compile errors with TList code.

22 messages · 10 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter Williams

Hi All,
I have uploaded my project with compile time errors to here:> Download link: > http://hotfile.com/dl/116917459/8effac0/dtm_maker_002.zip.htmlAnd I am getting these errors: Options changed, recompiling clean with -BHint: Start of reading config file /etc/fpc.cfgHint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 2.4.2-0 [2010/11/11] for i386Copyright (c) 1993-2010 by Florian KlaempflTarget OS: Linux for i386Compiling island_maker.lprCompiling unit1.pasCompiling set_max.pasunit1.pas(191,18) Error: No member is provided to access propertyunit1.pas(192,21) Error: No member is provided to access propertyunit1.pas(193,20) Error: No member is provided to access propertyunit1.pas(194,10) Error: No member is provided to access propertyunit1.pas(195,10) Error: No member is provided to access propertyunit1.pas(196,24) Error: No member is provided to access propertyunit1.pas(197,14) Error: No member is provided to access propertyunit1.pas(498,37) Error: Incompatible type for arg no. 3: Got "Array[1..2] Of AnsiString", expected "description_type"unit1.pas(184,21) Hint: Found declaration: constructor TIsland.Create(const Terrain_type,const Char,const description_type,const LongInt,const LongInt,const LongInt,const exit_type);unit1.pas(503,15) Error: Identifier not found "myList"unit1.pas(521,12) Error: Illegal qualifierunit1.pas(529,14) Warning: range check error while evaluating constantsunit1.pas(540,26) Error: Illegal qualifierunit1.pas(542,17) Error: Illegal qualifierunit1.pas(544,43) Error: Illegal qualifierunit1.pas(545,34) Error: Illegal qualifierunit1.pas(546,34) Error: Illegal qualifierunit1.pas(550,43) Error: Illegal qualifierunit1.pas(559,12) Error: Illegal qualifierunit1.pas(588,63) Error: Incompatible type for arg no. 7: Got "Pointer", expected "exit_type"unit1.pas(184,21) Hint: Found declaration: constructor TIsland.Create(const Terrain_type,const Char,const description_type,const LongInt,const LongInt,const LongInt,const exit_type);unit1.pas(607) Fatal: There were 18 errors compiling module, stopping These errors relate to me modifying my code to try to use a TList. Could someone please look at my code and see if you can point of my errors and fixes. Best Regards,Peter E WilliamsHobart, Australia

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110506/13300726/attachment-0001.html>

Reply by email

Peter Williams
to Peter Williams

Hi All,
I have copied the relevant unit to pastebin.com and here it is: http://pastebin.com/2v4xw4ep
unit1.pas(191,18) Error: No member is provided to access propertyunit1.pas(192,21) Error: No member is provided to access propertyunit1.pas(193,20) Error: No member is provided to access propertyunit1.pas(194,10) Error: No member is provided to access propertyunit1.pas(195,10) Error: No member is provided to access propertyunit1.pas(196,24) Error: No member is provided to access propertyunit1.pas(197,14) Error: No member is provided to access property line 191 follows:constructor TIsland.Create(const ATerrain : Terrain_type; const ATerrain_char : char; const Adescription : description_type; const Ax, Ay, Alocation_number : integer; const Aexits : exit_type );begin // Save the passed parameters self.Terrain := ATerrain; self.Terrain_char := ATerrain_char; self.description := Adescription; self.x := Ax; self.y := Ay; self.location_number := Alocation_number; self.exits := Aexits;end; Can anyone see what I am doing wrong here, and how do I fix this? Best Regards,PEW

From:
To:
Date: Fri, 6 May 2011 17:17:36 +1000
Subject: [Lazarus] dtm_maker project compile errors with TList code.

Hi All,
I have uploaded my project with compile time errors to here:> Download link: > http://hotfile.com/dl/116917459/8effac0/dtm_maker_002.zip.htmlAnd I am getting these errors: Options changed, recompiling clean with -BHint: Start of reading config file /etc/fpc.cfgHint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 2.4.2-0 [2010/11/11] for i386Copyright (c) 1993-2010 by Florian KlaempflTarget OS: Linux for i386unit1.pas(191,18) Error: No member is provided to access propertyunit1.pas(192,21) Error: No member is provided to access propertyunit1.pas(193,20) Error: No member is provided to access propertyunit1.pas(194,10) Error: No member is provided to access propertyunit1.pas(195,10) Error: No member is provided to access propertyunit1.pas(196,24) Error: No member is provided to access propertyunit1.pas(197,14) Error: No member is provided to access propertyCompiling island_maker.lprCompiling unit1.pasCompiling set_max.pasunit1.pas(191,18) Error: No member is provided to access propertyunit1.pas(192,21) Error: No member is provided to access propertyunit1.pas(193,20) Error: No member is provided to access propertyunit1.pas(194,10) Error: No member is provided to access propertyunit1.pas(195,10) Error: No member is provided to access propertyunit1.pas(196,24) Error: No member is provided to access propertyunit1.pas(197,14) Error: No member is provided to access propertyunit1.pas(498,37) Error: Incompatible type for arg no. 3: Got "Array[1..2] Of AnsiString", expected "description_type"unit1.pas(184,21) Hint: Found declaration: constructor TIsland.Create(const Terrain_type,const Char,const description_type,const LongInt,const LongInt,const LongInt,const exit_type);unit1.pas(503,15) Error: Identifier not found "myList"unit1.pas(521,12) Error: Illegal qualifierunit1.pas(529,14) Warning: range check error while evaluating constantsunit1.pas(540,26) Error: Illegal qualifierunit1.pas(542,17) Error: Illegal qualifierunit1.pas(544,43) Error: Illegal qualifierunit1.pas(545,34) Error: Illegal qualifierunit1.pas(546,34) Error: Illegal qualifierunit1.pas(550,43) Error: Illegal qualifierunit1.pas(559,12) Error: Illegal qualifierunit1.pas(588,63) Error: Incompatible type for arg no. 7: Got "Pointer", expected "exit_type"unit1.pas(184,21) Hint: Found declaration: constructor TIsland.Create(const Terrain_type,const Char,const description_type,const LongInt,const LongInt,const LongInt,const exit_type);unit1.pas(607) Fatal: There were 18 errors compiling module, stopping These errors relate to me modifying my code to try to use a TList. Could someone please look at my code and see if you can point of my errors and fixes. Best Regards,Peter E WilliamsHobart, Australia

Reply by email

Luk Vandelaer
to Peter Williams

Your constructor should be something like

constructor TIsland.Create(const ATerrain : Terrain_type;
         const ATerrain_char : char;
         const Adescription : description_type;
         const Ax, Ay, Alocation_number : integer;
         const Aexits : exit_type );
begin
  // Save the passed parameters
  self.ATerrain   := ATerrain;
  self.ATerrain_char := ATerrain_char;
  self.Adescription := Adescription;
  self.Ax := Ax;
  self.Ay := Ay;
  self.Alocation_number := Alocation_number;
  self.Aexits := Aexits;
end;

You declared the properties as read only, so assignments are not possible, instead you should make the assignments to the private fields that the properties will read.

Luk

Reply by email

Henry Vermaak
to Peter Williams: I have copied the relevant unit to pastebin.com and here it is:…
Peter Williams wrote 24 lines
Hi All, I have copied the relevant unit to pastebin.com and here it is: http://pastebin.com/2v4xw4ep <http://pastebin.com/2v4xw4ep> unit1.pas(191,18) Error: No member is provided to access property unit1.pas(192,21) Error: No member is provided to access property unit1.pas(193,20) Error: No member is provided to access property unit1.pas(194,10) Error: No member is provided to access property unit1.pas(195,10) Error: No member is provided to access property unit1.pas(196,24) Error: No member is provided to access property unit1.pas(197,14) Error: No member is provided to access property line 191 follows: constructor TIsland.Create(const ATerrain : Terrain_type; const ATerrain_char : char; const Adescription : description_type; const Ax, Ay, Alocation_number : integer; const Aexits : exit_type ); begin // Save the passed parameters self.Terrain := ATerrain;

I don't know why this is happening, but your naming scheme is confusing. The function parameters are o.k., but it's common to prefix private variables with "F", so rename the private variable ATerrain to FTerrain (hint: use F2 to rename an identifier). Then you can do:

FTerrain := ATerrain;
etc.

Henry

Reply by email

Peter Williams
to Henry Vermaak

Hi
The new version of unit1.pas is here:
http://pastebin.com/vNdNeHQe
Options changed, recompiling clean with -BHint: Start of reading config file /etc/fpc.cfgHint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 2.4.2-0 [2010/11/11] for i386Copyright (c) 1993-2010 by Florian KlaempflTarget OS: Linux for i386Compiling island_maker.lprCompiling unit1.pasunit1.pas(98,3) Error: Identifier not found "Generic"unit1.pas(98,3) Error: Error in type definitionunit1.pas(98,3) Fatal: Syntax error, ";" expected but "identifier TLIST" found type map_detail = record FTerrain : Terrain_type; FTerrain_char : char; Fdescription : description_type; Fx, Fy, Flocation_number : integer; Fexits : exit_type; end;

  // The Island class definition  TIsland = Generic    // line 98  TList(map_detail);    Items = array of map_detail;  end;

As you can see I am having problems defining a Generic TList. Can someone please point out to me what I'm doing wrong here. Best Regards,PEW

Show quoted text 18 lines
Date: Fri, 6 May 2011 11:55:27 +0100 From: To: Subject: Re: [Lazarus] dtm_maker project compile errors with TList code. On 06/05/11 11:50, Luk Vandelaer wrote: > > You declared the properties as read only, so assignments are not possible, Hehe, of course. Silly me for not noticing this. Henry -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110507/5c75fe0e/attachment.html>

Reply by email

Peter Williams
to Mattias Gaertner

Hi Mattias.

Show quoted text 6 lines
Date: Fri, 6 May 2011 17:07:55 +0200 From: To: Subject: Re: [Lazarus] dtm_maker project compile errors with TList code. see the unit fgl for examples of generics.

Without meaning to ask the obvious question, where can I find the 'fgl' unit ? Please quote the path or url for it. I used the find command on my Linux system and it was not found. I have a Lazarus folder in my home folder. PEW

Show quoted text 8 lines
Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110507/d3cc893d/attachment.html>

Reply by email

Peter Williams
to Peter Williams

Hi Mattias,
I found the fgl unit. It was just a matter of adding it to the uses clause the using the right click 'find declaration'. Thanks.
PEW

From:
To:
Date: Sat, 7 May 2011 01:13:25 +1000
Subject: Re: [Lazarus] dtm_maker project compile errors with TList code.

Hi Mattias.

Show quoted text 6 lines
Date: Fri, 6 May 2011 17:07:55 +0200 From: To: Subject: Re: [Lazarus] dtm_maker project compile errors with TList code. see the unit fgl for examples of generics.

Without meaning to ask the obvious question, where can I find the 'fgl' unit ? Please quote the path or url for it. I used the find command on my Linux system and it was not found. I have a Lazarus folder in my home folder. PEW

Show quoted text 8 lines
Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Peter Williams
to Peter Williams

Hi,
Options changed, recompiling clean with -BHint: Start of reading config file /etc/fpc.cfgHint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 2.4.2-0 [2010/11/11] for i386Copyright (c) 1993-2010 by Florian KlaempflTarget OS: Linux for i386Compiling island_maker.lprCompiling unit1.pasunit1.pas(144,19) Error: Generics without specialization cannot be used as a type for a variableunit1.pas(152,1) Fatal: There were 1 errors compiling module, stopping http://62.166.198.202/bug_view_advanced_page.php?bug_id=18101 (0043710)
Florian Kl?mpfl (administrator)
2010-11-29 10:47

Please use always the latest release compiler (2.4.2) as starting compiler to build a new fpc.

NB - I am using FPC 2.4.2.
type  Terrain_type = (Land, Sea);
  exit_type = array[ directions ] of integer;
  description_type = array[1..2] of string;
  Tmap_detail = Object                 FTerrain : Terrain_type;                 FTerrain_char : char;                 Fdescription : description_type;                 Fx, Fy, Flocation_number : integer;                 Fexits : exit_type;               end;
  // The Island class definition  Generic TIsland<T> = class      Items : array of Tmap_detail;    public    constructor Create(AList: TList);: [Lazarus] dtm_maker project compile errors with TList code.    procedure Add( Value : Tmap_detail );  end;        var  Form1: TForm1;  Island : TIsland; // line 144
Unit1.pas >>> http://pastebin.com/wuEft4Kb
Best Regards,PEW

From:
To:
Date: Sat, 7 May 2011 01:17:39 +1000
Subject: Re: [Lazarus] dtm_maker project compile errors with TList code.

Hi Mattias,
I found the fgl unit. It was just a matter of adding it to the uses clause the using the right click 'find declaration'. Thanks.
PEW

From:
To:
Date: Sat, 7 May 2011 01:13:25 +1000
Subject: Re: [Lazarus] dtm_maker project compile errors with TList code.

Hi Mattias.

Show quoted text 6 lines
Date: Fri, 6 May 2011 17:07:55 +0200 From: To: Subject: Re: [Lazarus] dtm_maker project compile errors with TList code. see the unit fgl for examples of generics.

Without meaning to ask the obvious question, where can I find the 'fgl' unit ? Please quote the path or url for it. I used the find command on my Linux system and it was not found. I have a Lazarus folder in my home folder. PEW

Show quoted text 8 lines
Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sven Barth
to Peter Williams
Peter Williams wrote 54 lines
Hi, Options changed, recompiling clean with -B Hint: Start of reading config file /etc/fpc.cfg Hint: End of reading config file /etc/fpc.cfg Free Pascal Compiler version 2.4.2-0 [2010/11/11] for i386 Copyright (c) 1993-2010 by Florian Klaempfl Target OS: Linux for i386 Compiling island_maker.lpr Compiling unit1.pas unit1.pas(144,19) Error: Generics without specialization cannot be used as a type for a variable unit1.pas(152,1) Fatal: There were 1 errors compiling module, stopping http://62.166.198.202/bug_view_advanced_page.php?bug_id=18101 (0043710) Florian Kl?mpfl (administrator) 2010-11-29 10:47 Please use always the latest release compiler (2.4.2) as starting compiler to build a new fpc. NB - I am using FPC 2.4.2. type Terrain_type = (Land, Sea); exit_type = array[ directions ] of integer; description_type = array[1..2] of string; Tmap_detail = Object FTerrain : Terrain_type; FTerrain_char : char; Fdescription : description_type; Fx, Fy, Flocation_number : integer; Fexits : exit_type; end; // The Island class definition Generic TIsland<T> = class Items : array of Tmap_detail; public constructor Create(AList: TList);: [Lazarus] dtm_maker project compile errors with TList code. procedure Add( Value : Tmap_detail ); end; var Form1: TForm1; Island : TIsland; // line 144 Unit1.pas >>> http://pastebin.com/wuEft4Kb

Why do you declare TIsland as a generic if you don't use the type "T" anywhere?

Nevertheless, you need to declare a specialized type of a generic, so you're able to use it.

Example:

type
   TIntegerIsland = specialize TIsland<Integer>;
var
   Island: TIntegerIsland;
(...)

Regards,
Sven

Reply by email

Peter Williams
to Sven Barth

Hi Sven & all,

Show quoted text 75 lines
Date: Fri, 6 May 2011 22:06:55 +0200 From: To: Subject: Re: [Lazarus] Error: Generics without specialization cannot be used as a type for a variable On 06.05.2011 17:58, Peter Williams wrote: > Hi, > > Options changed, recompiling clean with -B > Hint: Start of reading config file /etc/fpc.cfg > Hint: End of reading config file /etc/fpc.cfg > Free Pascal Compiler version 2.4.2-0 [2010/11/11] for i386 > Copyright (c) 1993-2010 by Florian Klaempfl > Target OS: Linux for i386 > Compiling island_maker.lpr > Compiling unit1.pas > unit1.pas(144,19) Error: Generics without specialization cannot be used > as a type for a variable > unit1.pas(152,1) Fatal: There were 1 errors compiling module, stopping > > http://62.166.198.202/bug_view_advanced_page.php?bug_id=18101 > > (0043710) > Florian Kl?mpfl (administrator) > 2010-11-29 10:47 > > Please use always the latest release compiler (2.4.2) as starting > compiler to build a new fpc. > > > NB - I am using FPC 2.4.2. > > type > Terrain_type = (Land, Sea); > > exit_type = array[ directions ] of integer; > > description_type = array[1..2] of string; > > Tmap_detail = Object > FTerrain : Terrain_type; > FTerrain_char : char; > Fdescription : description_type; > Fx, Fy, Flocation_number : integer; > Fexits : exit_type; > end; > > // The Island class definition > Generic TIsland<T> = class > Items : array of Tmap_detail; > public > constructor Create(AList: TList);: [Lazarus] dtm_maker project compile > errors with TList code. > procedure Add( Value : Tmap_detail ); > end; > var > Form1: TForm1; > Island : TIsland; // line 144 > > Unit1.pas >>> http://pastebin.com/wuEft4Kb Why do you declare TIsland as a generic if you don't use the type "T" anywhere? Nevertheless, you need to declare a specialized type of a generic, so you're able to use it. Example: type TIntegerIsland = specialize TIsland<Integer>; var Island: TIntegerIsland; (...)

Okay, except that Island is not meant to be an integer. See here: line 88Tmap_detail = Object FTerrain : Terrain_type; FTerrain_char : char; Fdescription : description_type; Fx, Fy, Flocation_number : integer; Fexits : exit_type; end; // The Island class definition Generic TIsland<T> = class Items : array of Tmap_detail; public constructor Create(AList: TList); procedure Add( Value : Tmap_detail ); end; So, as you can see, I am trying to define a Generic (or possibly a Specialize) of type: an array of Tmap_detail. How do I correctly define this??? The reason why I am choosing a Generic or Specialize is so that I have accept to the "Sort" procedure of TList. I am not sure if I am doing this correctly. Best Regards,Peter

Show quoted text 9 lines
Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110509/ae3a364b/attachment-0001.html>

Reply by email

Peter Williams
to Peter Williams

Hi All,

From:
To:
Date: Mon, 9 May 2011 16:32:04 +1000
Subject: Re: [Lazarus] Error: Generics without specialization cannot be used as a type for a variable

Hi Sven & all,

Show quoted text 75 lines
Date: Fri, 6 May 2011 22:06:55 +0200 From: To: Subject: Re: [Lazarus] Error: Generics without specialization cannot be used as a type for a variable On 06.05.2011 17:58, Peter Williams wrote: > Hi, > > Options changed, recompiling clean with -B > Hint: Start of reading config file /etc/fpc.cfg > Hint: End of reading config file /etc/fpc.cfg > Free Pascal Compiler version 2.4.2-0 [2010/11/11] for i386 > Copyright (c) 1993-2010 by Florian Klaempfl > Target OS: Linux for i386 > Compiling island_maker.lpr > Compiling unit1.pas > unit1.pas(144,19) Error: Generics without specialization cannot be used > as a type for a variable > unit1.pas(152,1) Fatal: There were 1 errors compiling module, stopping > > http://62.166.198.202/bug_view_advanced_page.php?bug_id=18101 > > (0043710) > Florian Kl?mpfl (administrator) > 2010-11-29 10:47 > > Please use always the latest release compiler (2.4.2) as starting > compiler to build a new fpc. > > > NB - I am using FPC 2.4.2. > > type > Terrain_type = (Land, Sea); > > exit_type = array[ directions ] of integer; > > description_type = array[1..2] of string; > > Tmap_detail = Object > FTerrain : Terrain_type; > FTerrain_char : char; > Fdescription : description_type; > Fx, Fy, Flocation_number : integer; > Fexits : exit_type; > end; > > // The Island class definition > Generic TIsland<T> = class > Items : array of Tmap_detail; > public > constructor Create(AList: TList);: [Lazarus] dtm_maker project compile > errors with TList code. > procedure Add( Value : Tmap_detail ); > end; > var > Form1: TForm1; > Island : TIsland; // line 144 > > Unit1.pas >>> http://pastebin.com/wuEft4Kb Why do you declare TIsland as a generic if you don't use the type "T" anywhere? Nevertheless, you need to declare a specialized type of a generic, so you're able to use it. Example: type TIntegerIsland = specialize TIsland<Integer>; var Island: TIntegerIsland; (...)
Okay, except that Island is not meant to be an integer. See here:
line 88Tmap_detail = Object                 FTerrain : Terrain_type;                 FTerrain_char : char;                 Fdescription : description_type;                 Fx, Fy, Flocation_number : integer;                 Fexits : exit_type;               end;   // The Island class definition  Generic TIsland<T> = class      Items : array of Tmap_detail;    public    constructor Create(AList: TList);    procedure Add( Value : Tmap_detail );  end;
So, as you can see, I am trying to define a Generic (or possibly a Specialize) of type: an array of Tmap_detail. How do I correctly define this??? The reason why I am choosing a Generic or Specialize is so that I have accept to the "Sort" procedure of TList. I am not sure if I am doing this correctly. Best Regards,>Peter

I have (though all of these posts) been trying to follow the instructions for GENERICS on this page: http://wiki.lazarus.freepascal.org/Generics
This page makes no reference to SPECIALIZE keyword. Can someone please provide an example of using a TList and an object (as in my code) so that I had access to a custom Tlist with the Sort procedure... which is really my reason for needing this. Best Regards,Peter

Show quoted text 9 lines
> Regards, > Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Lukasz Sokol
to Peter Williams

Hi Peter,
I recall you are using the lazarus mailing list to send posts/mails, but you use gmane as news reader ? (if it is not your case, ignore above statement...)

From the headers it appears you are using Exim to post.

It is incredibly frustrating since something mangles tabs/spaces/newlines on the way (AND I don't think it's my Thunderbird...? because everybody else's posts are OK) rendering the code you post completely unreadable.

Annotated below:

On 10/05/2011 01:28, Peter Williams wrote:
[...]

Okay, except that Island is not meant to be an integer. See here:

the below code is received as one long line, totally unformatted, totally no newlines, quoted by Thunderbird, even in quoting I see one long line (reader window wraps it automatically, thus becoming even less readable...)
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

line 88Tmap_detail = Object FTerrain : Terrain_type; FTerrain_char : char; Fdescription : description_type; Fx, Fy, Flocation_number : integer; Fexits : exit_type; end; // The Island class definition Generic TIsland<T> = class Items : array of Tmap_detail; public constructor Create(AList: TList); procedure Add( Value : Tmap_detail ); end;

[...]

I have (though all of these posts) been trying to follow the instructions for GENERICS on this page: http://wiki.lazarus.freepascal.org/Generics This page makes no reference to SPECIALIZE keyword.

also the below line I quote I can only see a very very long one, no line breaks.

Can someone please provide an example of using a TList and an object (as in my code) so that I had access to a custom Tlist with the Sort procedure... which is really my reason for needing this. Best Regards,Peter

(My mailer/news reader is Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Thunderbird/3.1.10 )

I'm not using automatic wordwrap in my postings too, because code sometimes exceeds 80 chars and thunderbird is less forgiving than Lazarus' SynEdit when it comes to wrapping; But at least please try to format your code manually when you paste it...

If nobody else sees this but me, feel free to ignore; but if somebody has a similar issue reading your posts, please back me :)

Kind Regards,
Lukasz

Reply by email

Peter Williams
to Peter Williams: From: To: Date: Mon, 9 May 2011 16:32:04 +1000 Subject: Re: [Lazarus] Error: Generics…

Hi All,
[snip]> >> > Unit1.pas >>> http://pastebin.com/wuEft4Kb> > Why do you declare TIsland as a generic if you don't use the type "T" > anywhere? I have (though all of these posts) been trying to follow the instructions for GENERICS on this page:http://wiki.lazarus.freepascal.org/GenericsThis page makes no reference to SPECIALIZE keyword. That is where I got the reference to type "T".Can someone please provide an example of using a TList and an object (as in my code) so that I had access to a custom Tlist with the Sort procedure... which is really my reason for needing this.

> Nevertheless, you need to declare a specialized type of a generic, so > you're able to use it.> > Example:> > type> TIntegerIsland = specialize TIsland<Integer>;> > var> Island: TIntegerIsland;> (...)
Okay, except that Island is not meant to be an integer. See here:
line 88Tmap_detail = Object                 FTerrain : Terrain_type;                 FTerrain_char : char;                 Fdescription : description_type;                 Fx, Fy, Flocation_number : integer;                 Fexits : exit_type;               end;   // The Island class definition  Generic TIsland<T> = class      Items : array of Tmap_detail;    public    constructor Create(AList: TList);    procedure Add( Value : Tmap_detail );  end;
So, as you can see, I am trying to define a Generic (or possibly a Specialize) of type: an array of Tmap_detail. How do I correctly define this??? The reason why I am choosing a Generic or Specialize is so that I have accept to the "Sort" procedure of TList. I am not sure if I am doing this correctly. Best Regards,>Peter

Best Regards,Peter

>> Regards,>> Sven>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110511/ee0c3083/attachment.html>

Reply by email

Juha gmail
to Lukasz Sokol: I recall you are using the lazarus mailing list to send posts/mails, but you use gmane as…

Lukasz Sokol kirjoitti tiistai, 10. toukokuuta 2011 11:38:20:

If nobody else sees this but me, feel free to ignore; but if somebody has a similar issue reading your posts, please back me :)

Yes I can back you. The mails are quite unreadable, and the very latest mail still has the same problem.
Peter, please pay attention to your post formatting. Use a proper mail client for example.

Regards,
Juha

Reply by email

Hans-Peter Diettrich
to Peter Williams: [snip]> >> > Unit1.pas >>> http://pastebin.com/wuEft4Kb> > Why do you declare TIsland as…
>The reason why I am choosing a Generic or Specialize is so that I have accept to the "Sort" procedure of TList. I am not sure if I am doing this correctly.

The Sort method requires a user-supplied *compare function*. Only that function must know about the type and contents of the list elements. In the implementation of that function you cast the given pointers into the real type of the list elements. That's all, no generics are nice when you want to implement lists, which only accept elements of one specific type. Have a look at the Contnrs unit, that defines several descendants of TList. E.g. a TObjectList only accepts TObject items, a TComponentList only accepts TComponent items.

Take e.g. a TObjectList, and replace all occurences of "TObject" by "<T>", to make it a generic class:

TMyList<T> = class(TList)
...

   function Add(AObject: <T>): Integer;

...
end;

Now you can create your own TComponentList like TMyList<TComponent>.

Please find out the exact syntax yourself, I never used generics in Lazarus.

Sorting such a list looks more complicated to me - but perhaps I'm wrong. The simple approach would look like:

Add a generic Compare function:
   TMyCompare<T> = function(Item1, Item2: <T>): integer;
and in TMyList<T> add:
   procedure Sort(Compare: TMyCompare<T>);
and implement it to call the TList.Sort method:
   inherited Sort(TListCompare(Compare));

This should result in an error message, because the TListCompare function has Pointers as arguments, while the specialized function has <T> type arguments. The next step were an adaptation of the Sort method, copied from TList, so that the TMyList.Sort procedure calls the specialized Compare:TMyCompare<T> function.

DoDi

Reply by email

Graeme Geldenhuys
to Lukasz Sokol: I recall you are using the lazarus mailing list to send posts/mails, but you use gmane as…
Lukasz Sokol wrote 5 lines
the below code is received as one long line, totally unformatted, totally no newlines, quoted by Thunderbird, even in quoting I see one long line (reader window wraps it automatically, thus becoming even less readable...)

Yes, that is because his email client sends each email as HTML & Plain Text, and the plain text is auto-generated, thus rubbish formatting. I also use Mozilla Thundebird. Peter's email was viewable on my side because my mailer settings in "View > Message body as > Original HTML", but when I reply, I post as plain-text, irrespective of what the original message format was.

One also gets some problems when using a desktop email client, but posting via Gmail's SMTP server. For some reason Gmail mangles long Subject lines by inserting TAB characters after the first 50 or so characters... Very weird, and I haven't found a work-around for that yet.

Very good email clients that don't try and screw too much with ones emails and formatting are: The Bat, Sylpheed and PM-Mail 2000.

Even Mozilla Thunderbird mangles your emails even with the "plain text" setting enabled. All this and suggested settings or work-arounds are covered in a Linux Kernel mailing list documentation page on how to send patches to the Linux Kernel mailing list.

Here is the link:
http://kernel.org/doc/Documentation/email-clients.txt

This link just proves in what a sad state the emails clients are. No consistency and standards. What is interesting is that many text based email clients behave better than the GUI counterparts, in this regard. It seems Old School rules! :)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Lukasz Sokol
to Graeme Geldenhuys

Hi Graeme,

Graeme Geldenhuys wrote 11 lines
On 10/05/2011 10:38, Lukasz Sokol wrote: > > the below code is received as one long line, totally unformatted, > totally no newlines, quoted by Thunderbird, even in quoting I see one > long line (reader window wraps it automatically, thus becoming even > less readable...) Yes, that is because his email client sends each email as HTML & Plain Text, and the plain text is auto-generated, thus rubbish formatting. I also use Mozilla Thundebird. Peter's email was viewable on my side because my mailer settings in "View > Message body as > Original HTML",

OOh. that made a lot of difference ...

but when I reply, I post as plain-text, irrespective of what the original message format was.

Yeah.So am I (or so I think ;).

Very good email clients that don't try and screw too much with ones emails and formatting are: The Bat, Sylpheed and PM-Mail 2000.

I'd rather go on writing an add-on to Thunderbird that fixes the issues than switch the mailer :))))))

Show quoted text 8 lines
Even Mozilla Thunderbird mangles your emails even with the "plain text" setting enabled. All this and suggested settings or work-arounds are covered in a Linux Kernel mailing list documentation page on how to send patches to the Linux Kernel mailing list. Here is the link: http://kernel.org/doc/Documentation/email-clients.txt

Yeah seen that, and I have my settiongs checked again ;) ...
in my 3.1.10, send_plaintext_flowed was already false; preformat mode, will see how it went ;)
(toggle wordwrap ext. I don't have time to look into about now...)

Show quoted text 5 lines
This link just proves in what a sad state the emails clients are. No consistency and standards. What is interesting is that many text based email clients behave better than the GUI counterparts, in this regard. It seems Old School rules! :)

OTOH no mention of EXIM there ;)

Thunderbird is sufficiently old-school for me thank you very much ;) (disclaimer: I work on Windows, and I have had lotsa trouble forcing my office into using thunderbird instead of webmail sites...) ;)

Regards, - Graeme -

Cheers,
Lukasz

Reply by email

David W Noon
to Lukasz Sokol

On Wed, 11 May 2011 12:20:29 +0100, Lukasz Sokol wrote about Re: [Lazarus] [OT/Readability] Re: Error: Generics without specialization cannot be used as a type for a variable:

On 11/05/2011 07:40, Graeme Geldenhuys wrote:

[snip]

Show quoted text 5 lines
> Very good email clients that don't try and screw too much with ones > emails and formatting are: The Bat, Sylpheed and PM-Mail 2000. I'd rather go on writing an add-on to Thunderbird that fixes the issues than switch the mailer :))))))

I have been using Claws-Mail, a fork of Sylpheed, for some few years now. It is *WAY* better than Thunderbird, especially if you use cryptographic signatures, as I do, and/or encrypted emails.

[snip]

OTOH no mention of EXIM there ;)

Exim is an SMTP server, not a mail reader (MUA).

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) ======================================================================= -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110511/9bbcc6cb/attachment.bin>

Reply by email

Lukasz Sokol
to David W Noon
David W Noon wrote 7 lines
On Wed, 11 May 2011 12:20:29 +0100, Lukasz Sokol wrote about Re: [snip] > OTOH no mention of EXIM there ;) Exim is an SMTP server, not a mail reader (MUA).

D'oh! :)
No X-Mailer field in PEW's previous emails, X)

but were showing 'received from' looking like Hotmail webmail OTOH.

(I think I understand now why he switched email addresses...)

THX,
Lukasz

Reply by email

Sven Barth
to Hans-Peter Diettrich: The Sort method requires a user-supplied *compare function*. Only that function must know…
Hans-Peter Diettrich wrote 9 lines
Take e.g. a TObjectList, and replace all occurences of "TObject" by "<T>", to make it a generic class: TMyList<T> = class(TList) ... function Add(AObject: <T>): Integer; ... end;

You need to use "T", not "<T>". The "<T>" after the class name is basically a type declaration. You can use multiple types, too:

TMyDictionary<TKey, TValue> = class
...

   function Find(aKey: TKey): TValue;
   ...

end;

Regards,
Sven

Reply by email