Re: [fpc-pascal] Generics in Objective Pascal?

2020-11-02 Thread Ryan Joseph via fpc-pascal
> On Nov 2, 2020, at 1:30 PM, Zoë Peterson via fpc-pascal > wrote: > > I have an NSView subclass with a bunch of fields and methods, and I wanted to > be able to optionally swap that out with a parallel version derived from > NSVisualEffectView without duplicating all of the code. I was

Re: [fpc-pascal] Generics in Objective Pascal?

2020-11-02 Thread Zoë Peterson via fpc-pascal
On 11/2/20 1:01 PM, Ryan Joseph via fpc-pascal wrote: What are you trying to do exactly? There are categories in ObjC but those don't allow fields (they're like helpers in Object Pascal). If you need to share data between a bunch of different NSView subclasses then all you can do is make a

Re: [fpc-pascal] Generics in Objective-C mode bug?

2019-11-11 Thread Ryan Joseph via fpc-pascal
> On Nov 11, 2019, at 1:25 PM, Sven Barth via fpc-pascal > wrote: > > Generics are not considered supported with Objective Pascal types. > There's really not any reason they shouldn't though. If you specialized with "string" for example that wouldn't be anything out of the ordinary so why

Re: [fpc-pascal] Generics in Objective-C mode bug?

2019-11-11 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mo., 11. Nov. 2019, 19:21: > Is this a bug I should report? Knowing what I do about generics now I > think the type check needs to be suspended until the type is actually > specialized. > Generics are not considered supported with Objective Pascal types.

[fpc-pascal] Generics in Objective-C mode bug?

2019-11-11 Thread Ryan Joseph via fpc-pascal
Is this a bug I should report? Knowing what I do about generics now I think the type check needs to be suspended until the type is actually specialized. {$mode objfpc} {$modeswitch objectivec2} program test; type generic TCocoaObject = objcclass (NSObject) // ERROR: The type

Re: [fpc-pascal] Generics: Error: Can't determine which overloaded function to call

2019-09-18 Thread LacaK
Work-around which produces good assembler without writting/reading intermediate variables: class function T2DPoint.Sqr(value: T): T; static; inline; begin   Result := value*value; end; function T2DPoint.Distance(P: T2DPoint): Single; inline; begin   Result := Sqrt(Sqr(x-P.x) + Sqr(y-P.y));

[fpc-pascal] Generics: Error: Can't determine which overloaded function to call

2019-09-18 Thread LacaK
Hi *, I have generics record, where one method computes distance between 2 points: function T2DPoint.Distance(P: T2DPoint): Single; begin   Result := Sqrt(Sqr(x-P.x) + Sqr(y-P.y)); end; But this does not compile as there are many versions of Sqr() in the scope Sqr(longint), Sqr(QWord),

Re: [fpc-pascal] Generics question

2018-12-03 Thread Martok
Am 03.12.2018 um 10:53 schrieb Martok: > I'll have to check the real-world code again, might be able to close this bug > as > "fixed in the mean time". Checked, works also in real code. I have added a note saying so on the bug. -- Regards, Martok Ceterum censeo b32079 esse sanandam.

Re: [fpc-pascal] Generics question

2018-12-03 Thread Sven Barth via fpc-pascal
Am Mo., 3. Dez. 2018, 10:53 hat Martok geschrieben: > Am 03.12.2018 um 08:00 schrieb Sven Barth via fpc-pascal: > > Because Delphi does not allow that either. We relaxed that however in > 3.1.1 and > > it should be part of 3.2.0. You can test the corresponding branch of you > want. > > Is this

Re: [fpc-pascal] Generics question

2018-12-03 Thread Martok
Am 03.12.2018 um 08:00 schrieb Sven Barth via fpc-pascal: > Because Delphi does not allow that either. We relaxed that however in 3.1.1 > and > it should be part of 3.2.0. You can test the corresponding branch of you > want. Is this related to ?

Re: [fpc-pascal] Generics question

2018-12-02 Thread Sven Barth via fpc-pascal
Am So., 2. Dez. 2018, 23:29 hat Bart geschrieben: > Hi, > > { TFoo } > > generic TFoo = class > procedure Bar; > end; > > { TFoo } > > procedure TFoo.Bar; > procedure localproc; > begin end; > begin > end; > > This will not compile (fpc 3.0.4): > gentest.lpr(35,4) Error: Generic

[fpc-pascal] Generics question

2018-12-02 Thread Bart
Hi, { TFoo } generic TFoo = class procedure Bar; end; { TFoo } procedure TFoo.Bar; procedure localproc; begin end; begin end; This will not compile (fpc 3.0.4): gentest.lpr(35,4) Error: Generic methods cannot have nested procedures While the message is clear, the reason for

Re: [fpc-pascal] Generics - extending TFPGObjectList

2018-07-26 Thread Sven Barth via fpc-pascal
Vojtěch Čihák schrieb am Do., 26. Juli 2018, 13:40: > Thanks for reply. > > > > Ad 2) I opened issue: https://bugs.freepascal.org/view.php?id=34037 > > > > Ad 1) Are there any plans for improvement of generic inheritance? Related > to my example, instead of > > > > generic TFPGObjectListEx =

Re: [fpc-pascal] Generics - extending TFPGObjectList

2018-07-26 Thread Vojtěch Čihák
via fpc-pascal Komu: fpc-pascal@lists.freepascal.org Datum: 26.07.2018 07:04 Předmět: Re: [fpc-pascal] Generics - extending TFPGObjectList Am 26.07.2018 um 02:31 schrieb Vojtěch Čihák:Hello,   I needed to extend TFPGObjectList and I found two wierd things (FPC 3.1.1 r39507):   program project1

Re: [fpc-pascal] Generics - extending TFPGObjectList

2018-07-25 Thread Sven Barth via fpc-pascal
Am 26.07.2018 um 02:31 schrieb Vojtěch Čihák: Hello, I needed to extend TFPGObjectList and I found two wierd things (FPC 3.1.1 r39507): program project1; {$mode objfpc}{$H+} uses   Classes, FGL; type   TBaseClass = class (TObject)   end;   TIDClass = class (TBaseClass)     ID:

[fpc-pascal] Generics - extending TFPGObjectList

2018-07-25 Thread Vojtěch Čihák
Hello,   I needed to extend TFPGObjectList and I found two wierd things (FPC 3.1.1 r39507):   program project1; {$mode objfpc}{$H+}   uses   Classes, FGL;   type   TBaseClass = class (TObject)   end;     TIDClass = class (TBaseClass)     ID: Integer;   end;     TNameIDClass = class (TIDClass)    

Re: [fpc-pascal] Generics vs templates

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 08:06 schrieb "Michael Schnell" : On 09.01.2018 08:04, Sven Barth via fpc-pascal wrote: But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to worse performance. Seemingly it is done that way.

Re: [fpc-pascal] Generics vs templates

2018-01-10 Thread Michael Schnell
On 09.01.2018 08:04, Sven Barth via fpc-pascal wrote: But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to worse performance. Seemingly it is done that way. I rather often did a kind of "Generics" in ANSI C by using Macros.

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 10.01.2018 05:10 schrieb "Ryan Joseph" : > On Jan 10, 2018, at 6:37 AM, Graeme Geldenhuys < mailingli...@geldenhuys.co.uk> wrote: > > When using the Generics.Collections unit of Delphi I can define a list class that can hold Integer data types, by doing the

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 10.01.2018 07:39 schrieb "Marco van de Voort" : In our previous episode, Sven Barth via fpc-pascal said: > Precisely these virtual methods are one point. They might not add much by > themselves, but if they're called for each Add or Remove operation they can > add quite a bit.

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said: > Precisely these virtual methods are one point. They might not add much by > themselves, but if they're called for each Add or Remove operation they can > add quite a bit. > Why do you think that the TFP(Object)List classes don't have

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Ryan Joseph
> On Jan 10, 2018, at 6:37 AM, Graeme Geldenhuys > wrote: > > When using the Generics.Collections unit of Delphi I can define a list class > that can hold Integer data types, by doing the following: > > var >IntList: TList; > begin >IntList :=

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Graeme Geldenhuys
On 2018-01-09 01:29, Ryan Joseph wrote: What does this have to do with generics exactly? Everything I guess. ;-) That was the point of my reply. When using the Generics.Collections unit of Delphi I can define a list class that can hold Integer data types, by doing the following: var

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Maciej Izak
2018-01-08 21:30 GMT+01:00 Graeme Geldenhuys : > Speaking of Generics and Benchmarks. Has anybody done some benchmarks on > FPC's Generics vs "old-school" TList and TObjectList. Recently I did a very > simple test with Delphi XE3 using TList and a stock TList.

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 09.01.2018 08:13 schrieb "Ryan Joseph" : > On Jan 9, 2018, at 2:04 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 09.01.2018 02:59 schrieb "Ryan Joseph" : > On Jan 9, 2018, at 3:30 AM, Graeme Geldenhuys < mailingli...@geldenhuys.co.uk> wrote: > > Recently I did a very simple test with Delphi XE3 using TList and a stock TList. Adding 50,000 and 200,000 integer values to each

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Giuliano Colla
Il 08/01/2018 21:30, Graeme Geldenhuys ha scritto: I was horified to find out how much slower Delphi's Generics were compared to TList and TObjectList I don't expect FPC behave much better. Whenever you move something from compile time to execution time you may gain in flexibility, but you

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 08.01.2018 12:52 schrieb "Ryan Joseph" : > On Jan 8, 2018, at 5:58 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > FPC essentially reparses a generic during specialization so I'd say that they definitely affect compile times. Does c++

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Ryan Joseph
> On Jan 8, 2018, at 5:58 PM, Sven Barth via fpc-pascal > wrote: > > FPC essentially reparses a generic during specialization so I'd say that they > definitely affect compile times. Does c++ not “specialize” in one location like FPC? looking at c++ code I

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 08.01.2018 08:50 schrieb "Ryan Joseph" : I was talking with a c++ developer who explained how templates are implemented in c++ and how use some recursive method which causes them to totally murder compile times. This isn’t the first I’ve heard of the problem though

[fpc-pascal] Generics vs templates

2018-01-07 Thread Ryan Joseph
I was talking with a c++ developer who explained how templates are implemented in c++ and how use some recursive method which causes them to totally murder compile times. This isn’t the first I’ve heard of the problem though and I recall some game studios who develop engines in c++ saying they

Re: [fpc-pascal] Generics Bug

2017-03-19 Thread African Wild Dog
2017-03-18 19:29 GMT-03:00 African Wild Dog : > 2017-03-18 18:41 GMT-03:00 Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org>: > > Nested specializations are currently not supported though they *might* >> work with 3.1.1. >> > > I will do test some tests with

Re: [fpc-pascal] Generics Bug

2017-03-18 Thread African Wild Dog
2017-03-18 18:41 GMT-03:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: Nested specializations are currently not supported though they *might* work > with 3.1.1. > I will do test some tests with 3.1.1. Thanks. Regards ___ fpc-pascal

Re: [fpc-pascal] Generics Bug

2017-03-18 Thread Sven Barth via fpc-pascal
Am 18.03.2017 22:41 schrieb "Sven Barth" : > > Am 18.03.2017 19:55 schrieb "African Wild Dog" : > > > > Hello, > > > > > > Please confirm this bug. > > > > The unit code bellow won't compile (fpc 3.0.2 - debian jessie amd64): > > > >

Re: [fpc-pascal] Generics Bug

2017-03-18 Thread Sven Barth via fpc-pascal
Am 18.03.2017 19:55 schrieb "African Wild Dog" : > > Hello, > > > Please confirm this bug. > > The unit code bellow won't compile (fpc 3.0.2 - debian jessie amd64): > > "generics_bug.pas(17,48) Fatal: Syntax error, "," expected but "<" found" > > === CODE === > > unit

[fpc-pascal] Generics Bug

2017-03-18 Thread African Wild Dog
Hello, Please confirm this bug. The unit code bellow won't compile (fpc 3.0.2 - debian jessie amd64): "generics_bug.pas(17,48) Fatal: Syntax error, "," expected but "<" found" === CODE === *unit* generics_bug; {$mode delphi} *interface* *type* TPair = *record* Key:

Re: [fpc-pascal] Generics and Scopes

2016-11-09 Thread African Wild Dog
2016-11-10 1:30 GMT-02:00 African Wild Dog : > 2016-11-07 14:15 GMT-02:00 Sven Barth : > >> Am 07.11.2016 15:58 schrieb "African Wild Dog" : >> > It is intended to change such compiler behavior in the future? It is >>

Re: [fpc-pascal] Generics and Scopes

2016-11-09 Thread African Wild Dog
2016-11-07 14:15 GMT-02:00 Sven Barth : > Am 07.11.2016 15:58 schrieb "African Wild Dog" : > > It is intended to change such compiler behavior in the future? It is > incompatible with Delphi and moreover it force us to break the >

Re: [fpc-pascal] Generics and Scopes

2016-11-07 Thread Sven Barth
Am 07.11.2016 15:58 schrieb "African Wild Dog" : > It is intended to change such compiler behavior in the future? It is incompatible with Delphi and moreover it force us to break the encapsulation of the Generic types. I can't answer this without you providing an example

Re: [fpc-pascal] Generics and Scopes

2016-11-07 Thread Michael Van Canneyt
On Mon, 7 Nov 2016, African Wild Dog wrote: Hello, I have tried to compile some delphi projects using the latest FPC (3.0.0) release, and i got several errors related to Ggenerics feature. Reading the FPC documentation (section 8.8 - A Word About Scope) i have found that FPC requires that

[fpc-pascal] Generics and Scopes

2016-11-07 Thread African Wild Dog
Hello, I have tried to compile some delphi projects using the latest FPC (3.0.0) release, and i got several errors related to Ggenerics feature. Reading the FPC documentation (section 8.8 - A Word About Scope) i have found that FPC requires that all external types and procedures used in the the

Re: [fpc-pascal] Generics: constructor restriction fail

2014-11-13 Thread silvioprog
On Tue, Nov 11, 2014 at 7:08 PM, Chriss Kalogeropoulos iz.iznog...@gmail.com wrote: Hi all, I am not sure about the constructor case but I consider the FPC implementation of generics much more powerful than Delphi's assuming that Sven's comment actually works as expected. The fact that the

Re: [fpc-pascal] Generics: constructor restriction fail

2014-11-11 Thread silvioprog
On Sat, Nov 1, 2014 at 9:04 AM, Sven Barth pascaldra...@googlemail.com wrote: On 31.10.2014 00:04, silvioprog wrote: Hello, Following this article: http://alex.ciobanu.org/?p=51 The compiler does not check the constructor restriction. Try this test: {$mode delphi} TTest = class

Re: [fpc-pascal] Generics: constructor restriction fail

2014-11-11 Thread Chriss Kalogeropoulos
Hi all, I am not sure about the constructor case but I consider the FPC implementation of generics much more powerful than Delphi's assuming that Sven's comment actually works as expected. The fact that the method invocation is actually checked on specialization and not on declaration means that

Re: [fpc-pascal] Generics: constructor restriction fail

2014-11-01 Thread Sven Barth
On 31.10.2014 00:04, silvioprog wrote: Hello, Following this article: http://alex.ciobanu.org/?p=51 The compiler does not check the constructor restriction. Try this test: {$mode delphi} TTest = class private // hidding the constructor to cause a compiler error constructor

[fpc-pascal] Generics: constructor restriction fail

2014-10-30 Thread silvioprog
Hello, Following this article: http://alex.ciobanu.org/?p=51 The compiler does not check the constructor restriction. Try this test: {$mode delphi} TTest = class private // hidding the constructor to cause a compiler error constructor Create; end; TGenT: class, constructor =

[fpc-pascal] Generics Syntax

2014-02-27 Thread Fabrício Srdic
Hello, Will the generics syntax change in the fpc 2.8? The fpc-generics-collection library ( http://forum.lazarus.freepascal.org/index.php?topic=20965.0) doesn't use the generic keyword to declare a generic class, which seems to be a more delphi-like way. It requires the fpc 2.7.1. Thanks

Re: [fpc-pascal] Generics Syntax

2014-02-27 Thread silvioprog
2014-02-27 19:36 GMT-03:00 Fabrício Srdic fabricio.sr...@gmail.com: Hello, Will the generics syntax change in the fpc 2.8? The fpc-generics-collection library ( http://forum.lazarus.freepascal.org/index.php?topic=20965.0) doesn't use the generic keyword to declare a generic class, which

Re: [fpc-pascal] Generics Syntax

2014-02-27 Thread leledumbo
FPC supports both Delphi and its own generics syntax. Nothing needs to be changed, but maybe FPC one will be enhanced more (it's already enhanced a lot since latest stable). -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Generics-Syntax-tp5718453p5718456.html

Re: [fpc-pascal] Generics Syntax

2014-02-27 Thread Fabrício Srdic
Thanks for clarifying! 2014-02-27 21:34 GMT-03:00 leledumbo leledumbo_c...@yahoo.co.id: FPC supports both Delphi and its own generics syntax. Nothing needs to be changed, but maybe FPC one will be enhanced more (it's already enhanced a lot since latest stable). -- View this message in

Re: [fpc-pascal] Generics and key words

2014-02-14 Thread Maciej Izak
Currently only in mode Delphi. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal also generics overload (TAT, TAT1, T2) don't work in objfpc... the main

Re: [fpc-pascal] Generics and key words

2014-02-13 Thread silvioprog
2014-02-13 5:43 GMT-02:00 Sven Barth pascaldra...@googlemail.com: Am 13.02.2014 01:28, schrieb silvioprog: Hello, Can I use it: TBrookActionTBrookEntity = class(TBrookObject) ... instead of?: generic TBrookActionTBrookEntity = class(TBrookObject) ... And, can I use it:

[fpc-pascal] Generics and key words

2014-02-12 Thread silvioprog
Hello, Can I use it: TBrookActionTBrookEntity = class(TBrookObject) ... instead of?: generic TBrookActionTBrookEntity = class(TBrookObject) ... And, can I use it: TPersonAction = class(TBrookActionTPerson) ... instead of?: TPersonAction = class(specialize TBrookActionTPerson) ... This

Re: [fpc-pascal] Generics and key words

2014-02-12 Thread Sven Barth
Am 13.02.2014 01:28, schrieb silvioprog: Hello, Can I use it: TBrookActionTBrookEntity = class(TBrookObject) ... instead of?: generic TBrookActionTBrookEntity = class(TBrookObject) ... And, can I use it: TPersonAction = class(TBrookActionTPerson) ... instead of?: TPersonAction =

[fpc-pascal] Generics - how to rewrite TOjectDictionary

2013-04-07 Thread Marius
Hello, It was many years ago i tried fpc/lazarus so i'm not up to speed with eveything. At this moment I'm trying to rewrite a piece of software from delphi to fpc/laz and i'm having trouble rewriting generics and in special the TObjectDictionary. Below shows how it is implemented in delphi. Is

Re: [fpc-pascal] Generics - how to rewrite TOjectDictionary

2013-04-07 Thread Dimitri Smits
Hi, Ever tried TStringList with Strings[] and Objects[] properties? kind regards, Dimitri Smits - Oorspronkelijk e-mail - Van: Marius mar...@lmspathologie.nl Aan: fpc-pascal@lists.freepascal.org Verzonden: Zondag 7 april 2013 18:48:02 Onderwerp: [fpc-pascal] Generics - how

Re: [fpc-pascal] Generics - how to rewrite TOjectDictionary

2013-04-07 Thread Sven Barth
Am 07.04.2013 23:09 schrieb Dimitri Smits smi...@telenet.be: Hi, Ever tried TStringList with Strings[] and Objects[] properties? The speciality of TObjectDirectory is that it frees the objects when an entry is deleted (similar to TObjectList). But I now remember that we added an OwnsObjects

Re: [fpc-pascal] Generics Compile Error, 2.4.2 vs 2.6.0

2012-02-13 Thread J.-c. Chu
If you are compiling the unit in Delphi mode, you’ll need to use the syntax of Delphi. * Generics are defined without the GENERIC keyword. * Generics are specialized without the SPECIALIZE keyword. * To define class-local types and variables, visibility specifiers need to be placed before

Re: [fpc-pascal] Generics Compile Error, 2.4.2 vs 2.6.0

2012-02-13 Thread David Copeland
Thanks very much. It now compiles! Dave. -Original Message- From: J.-c. Chu jc...@acm.org Reply-to: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Generics Compile Error, 2.4.2 vs

[fpc-pascal] Generics and Mac

2011-12-17 Thread Juha Manninen
I used generics in Lazarus code base for the first time, in TreeFilter component: TTreeNodeList = specialize TFPGListTTreeNode; and TBranchList = specialize TFPGObjectListTBranch; I works for me on Windows and Linux, with FPC 2.4.4 and 2.6.0 RC1. Now Zeljan reported it does not compile on

Re: [fpc-pascal] Generics vs TCollection

2011-11-10 Thread Graeme Geldenhuys
On 9 November 2011 22:08, Michael Van Canneyt michael@ wrote: Hm. I fail to see this: Where is the gain in that ? +1 -- Regards,   - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Re: [fpc-pascal] Generics vs TCollection

2011-11-09 Thread tcoq
michael.vancann...@wisa.be À: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Envoyé: Mardi 8 Novembre 2011 13h22:31 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [fpc-pascal] Generics vs TCollection ... The difference is mainly that in the case of TCollection

Re: [fpc-pascal] Generics vs TCollection

2011-11-09 Thread Felipe Monteiro de Carvalho
In my experience generics are very good, but they are not without problems. There are some limitations in the implementation and I have already hit some bumps in the road when using them (search the mailling list, I don't remember exactly the issues) But I can't compare them to collections,

Re: [fpc-pascal] Generics vs TCollection

2011-11-09 Thread Michael Van Canneyt
: [fpc-pascal] Generics vs TCollection ... The difference is mainly that in the case of TCollection(Item) you need to override the items property; With generics, you can skip this step. At the expense of copying the whole TCollection code each time you create a specialized descendent. Michael

[fpc-pascal] Generics vs TCollection

2011-11-08 Thread Graeme Geldenhuys
Hi, I was reviewing some old code that used TCollection TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem? -- Regards,   - Graeme - ___ fpGUI - a

Re: [fpc-pascal] Generics vs TCollection

2011-11-08 Thread Jonas Maebe
On 08 Nov 2011, at 10:55, Graeme Geldenhuys wrote: I was reviewing some old code that used TCollection TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem? At the very least, backward

Re: [fpc-pascal] Generics vs TCollection

2011-11-08 Thread michael . vancanneyt
On Tue, 8 Nov 2011, Graeme Geldenhuys wrote: Hi, I was reviewing some old code that used TCollection TCollectionItem descendants. This made me think... With the introduction of Generics, is there really still a need for TCollection/TCollectionItem? I have tons of code that uses them.

Re: [fpc-pascal] Generics vs TCollection

2011-11-08 Thread Graeme Geldenhuys
On 8 November 2011 11:58, Jonas Maebe wrote: At the very least, backward compatibility with existing code. We even still ship a Turbo Pascal-compatible objects unit. Please see my reply to Michael. I had no intentions in recommending the removal of TCollection. I'm just comparing

Re: [fpc-pascal] Generics vs TCollection

2011-11-08 Thread michael . vancanneyt
On Tue, 8 Nov 2011, Graeme Geldenhuys wrote: On 8 November 2011 12:13, michael.vancanneyt@... wrote: I have tons of code that uses them. Lazarus has tons of code that uses them. There is no way that we're going to rewrite all that stuff. Sorry for any confusion. I did not post this with

Re: [fpc-pascal] generics question

2011-05-14 Thread Sven Barth
I have not yet looked at the parsing of methods of generic classes during my work on the generics, but when I'll implement generic methods I'll try to take a look at your problem. Regards, Sven On 12.05.2011 12:37, Adrian Veith wrote: Hi, I try this: type TTestGenT = class

[fpc-pascal] generics question

2011-05-12 Thread Adrian Veith
Hi, I try this: type TTestGenT = class constructor Create(); class function Test(val: T): string; inline; end; function Blah(const val: Integer): string; inline; overload; begin Result:= IntToStr(val + 1); end; function Blah(const val: string): string; inline; overload; begin

Re: [fpc-pascal] Generics feature status

2011-04-30 Thread Sven Barth
On 30.04.2011 03:15, Paul Ishenin wrote: 30.04.2011 3:28, leledumbo wrote: I see now that generics have improved a lot since latest release, we even have Delphi compatible syntax in Delphi mode. Recursive generic type is supported as well now (finally, I can continue my data structure library

Re: [fpc-pascal] Generics feature status

2011-04-29 Thread Anthony Walter
Is this true? I'd really like to see generics that with a mode where it is possible to say with the following syntax (compatible with Delphi): type IDelegateT = interface procedure Add(const Handler: T); procedure Remove(const Handler: T); end; And then specialize using the following

Re: [fpc-pascal] Generics feature status

2011-04-29 Thread Paul Ishenin
30.04.2011 3:28, leledumbo wrote: I see now that generics have improved a lot since latest release, we even have Delphi compatible syntax in Delphi mode. Recursive generic type is supported as well now (finally, I can continue my data structure library :)). Seeing these facts, what's the status

[fpc-pascal] Generics in Delphi mode?

2011-03-30 Thread timveldhuizen
Hi. I just found out today that generics also work in Free Pascal (and as I understand it, it was even implemented before it was added in delphi :) ). However, the way it was implemented makes me frown a bit. Not that it is that bad or unusable or illogical, but as I use Delphi mode, I was

Re: [fpc-pascal] Generics in Delphi mode?

2011-03-30 Thread Žilvinas Ledas
Hi, On 2011-03-30 21:59, timveldhuizen wrote: I hope very much that this will be changed to a delphi compatible style It is already implemented in Trunk ;) Regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Generics in Delphi mode?

2011-03-30 Thread Tim Veldhuizen
Hi, 2011/3/30 Žilvinas Ledas zilvinas.le...@dict.lt It is already implemented in Trunk ;) Wonderful! I can hardly wait for it to be released in a stable version. I have version 2.4.0 here as the default freepascal package in Fedora 13, but I'll give the new release a spin as soon as it's out. I

Re: [fpc-pascal] Generics in Delphi mode?

2011-03-30 Thread Jonas Maebe
On 30 Mar 2011, at 21:28, Tim Veldhuizen wrote: Wonderful! I can hardly wait for it to be released in a stable version. I have version 2.4.0 here as the default freepascal package in Fedora 13, but I'll give the new release a spin as soon as it's out. I don't see a release date announcement

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Sven Barth
On 19.12.2010 02:51, David Emerson wrote: Sven Barth wrote: I've now looked at your example code in more detail (I was working the last time I wrote you). Where did you define _t_point? I only found a t_point in your second mail. _t_point is part of the template list. Eh... yes, I've

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Sven Barth
On 19.12.2010 08:34, Honza wrote: 2010/12/19 David Emersondle...@angelbase.com: type generic gt_box_t_point,_num = class (_t_point) // FAILS :-( f_width, f_height : _num; end; I think it should fail according to the docs, see: http://www.freepascal.org/docs-html/ref/refse42.html

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread David Emerson
On Sat 18 Dec 2010, Honza wrote: 2010/12/19 David Emerson dle...@angelbase.com: type  generic gt_box_t_point,_num = class (_t_point)   // FAILS :-( f_width, f_height : _num; end; I think it should fail according to the docs, see:

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Honza
2010/12/19 Sven Barth pascaldra...@googlemail.com: There is a single placeholder _T. It will be substituted by a type identifier when the generic class is specialized. The identifier _T *may not be used for anything else than a placehoder*. According to the documentation I'd say that it

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Honza
2010/12/19 David Emerson dle...@angelbase.com: Please see my just sent reply to Sven. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Sven Barth
On 19.12.2010 13:03, Honza wrote: 2010/12/19 Sven Barthpascaldra...@googlemail.com: There is a single placeholder _T. It will be substituted by a type identifier when the generic class is specialized. The identifier _T *may not be used for anything else than a placehoder*. According to the

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread Honza
2010/12/19 Sven Barth pascaldra...@googlemail.com: While I DO agree with you (after some thinking about the consequences) that a base class should not be allowed to be specified by a template parameter (and this is the way it already is), I don't agree with you that the documentation states

Re: [fpc-pascal] generics class hierarchy

2010-12-19 Thread David Emerson
@David: Maybe you can restructure your class hierarchy to something like this (you'll need to be a bit creative here ^^): heh, no, my solution is to abandon generics :-) I used a find/replace script to make alternate classes with real values. Thanks for all your input, though. Thanks to you,

Re: [fpc-pascal] generics class hierarchy

2010-12-18 Thread David Emerson
Would you please state your FPC version the next time? (If you have stated I, but I haven't seen it: I'm sorry) Some problems might be fixed in the development version while they aren't in the latest release. I tried with both 2.4.2 and 2.5.1 (fetched via svn and compiled. Took me quite

Re: [fpc-pascal] generics class hierarchy

2010-12-18 Thread Sven Barth
On 18.12.2010 22:22, David Emerson wrote: Would you please state your FPC version the next time? (If you have stated I, but I haven't seen it: I'm sorry) Some problems might be fixed in the development version while they aren't in the latest release. I tried with both 2.4.2 and 2.5.1 (fetched

Re: [fpc-pascal] generics class hierarchy

2010-12-18 Thread David Emerson
Sven Barth wrote: I've now looked at your example code in more detail (I was working the last time I wrote you). Where did you define _t_point? I only found a t_point in your second mail. _t_point is part of the template list. I guess it's a limitation. Conceptually it doesn't seem that

Re: [fpc-pascal] generics class hierarchy

2010-12-18 Thread Honza
2010/12/19 David Emerson dle...@angelbase.com: type  generic gt_box_t_point,_num = class (_t_point)   // FAILS :-( f_width, f_height : _num; end; I think it should fail according to the docs, see: http://www.freepascal.org/docs-html/ref/refse42.html There is a single placeholder _T. It

Re: [fpc-pascal] generics class hierarchy

2010-12-17 Thread Sven Barth
Am 17.12.2010 03:30, schrieb David Emerson: err... my mistake. the error message was referring to a different problem, which I was blind to in my hurry. Sorry for all the messages. I'll shut up now. :) Would you please state your FPC version the next time? (If you have stated I, but I

[fpc-pascal] generics class hierarchy

2010-12-16 Thread David Emerson
Hi all, How can I use inheritance with generics? e.g. type generic gt_point_num = class ... end; generic gt_box_tpoint,_num = class (_tpoint) ... end; The above gives me an error; I've tried some other variations but haven't yet found anything that works Thanks, David

Re: [fpc-pascal] generics class hierarchy

2010-12-16 Thread David Emerson
I'll give a little more detail... Right now I have these non-generic types: t_point = class f_left, f_top : longint; // so named for descendents // several fields and methods to manage it as I need end; t_box = class (t_point) f_width, f_height : longint; // more fields and methods

Re: [fpc-pascal] generics class hierarchy

2010-12-16 Thread David Emerson
Well, I'm guessing generics aren't really ready to be fully used... I'm getting an error There is no method in an ancestor class to be overridden where the ancestor class was a specialized generic. Doesn't seem very promising for actual use. So I'm abandoning generics for now. Hopefully

Re: [fpc-pascal] generics class hierarchy

2010-12-16 Thread David Emerson
err... my mistake. the error message was referring to a different problem, which I was blind to in my hurry. Sorry for all the messages. I'll shut up now. :) On Thu 16 Dec 2010, David Emerson wrote: Well, I'm guessing generics aren't really ready to be fully used... I'm getting an error

Re: [fpc-pascal] Generics problem/question

2010-01-24 Thread Aleksa Todorovic
On Tue, Jan 19, 2010 at 18:35, Aleksa Todorovic alexi...@gmail.com wrote: On Mon, Jan 18, 2010 at 04:07, Aleksa Todorovic alexi...@gmail.com wrote: One (not very nice) way to have generic list of records is using macros. I've extracted definition of TFPGList, made it ordinary type, and did

Re: [fpc-pascal] Generics problem/question

2010-01-19 Thread Aleksa Todorovic
On Mon, Jan 18, 2010 at 04:07, Aleksa Todorovic alexi...@gmail.com wrote: The proper solution for this problem is not simple. Somehow, you will have to make operator = (const A, B: TPar) visible inside FGL unit (because of the way generics are currently implemented), or make compiler think

Re: [fpc-pascal] Generics problem/question

2010-01-18 Thread Aleksa Todorovic
On Fri, Jan 15, 2010 at 09:00, leledumbo leledumbo_c...@yahoo.co.id wrote: Ah... I can see it now: 711  function TFPGList.IndexOf(const Item: T): Integer; 712  begin 713    Result := 0; 714    {$info TODO: fix inlining to work! InternalItems[Result]^} 715    while (Result FCount) and

Re: [fpc-pascal] Generics problem/question

2010-01-15 Thread leledumbo
Ah... I can see it now: 711 function TFPGList.IndexOf(const Item: T): Integer; 712 begin 713Result := 0; 714{$info TODO: fix inlining to work! InternalItems[Result]^} 715while (Result FCount) and (PT(FList)[Result] Item) do 716 Inc(Result); 717if Result = FCount then 718

Re: [fpc-pascal] Generics problem/question

2010-01-14 Thread Honza
Hi all. At Mantis Florian already explained, why it is not possible to provide more information in the error message. Still he meanwhile managed to make it better. I got some time to return to this and now I'm here: 17:11 myn...@tux64:~/fpc/bugreports/20100105$ cat project1.pas program project1;

  1   2   >