Re: [fpc-pascal] Constants in generics tests

2019-02-24 Thread Ryan Joseph
I made one final commit and now I’m submitting a patch for review. I’ve probably made mistakes in the patch process but I want to get this into the pipeline so it’s not just sitting there wasting space on my computer. Tests are included now and the link to the source on git is included in the

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Ryan Joseph
> On Feb 15, 2019, at 1:52 PM, Jeppe Johansen wrote: > > Hi, > > Do you know why this doesn't work? Jeppe I got this fixed now so if you update and rebuild from git it should work now. Really stupid one liner mistake that took my all morning to find. I included this into the tests which

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Ryan Joseph
> On Feb 16, 2019, at 9:42 AM, Sven Barth via fpc-pascal > wrote: > > When you create the constant symbols for the specialization you need to make > sure that they belong to the surrounding symtable, not the specialized > generic. > I probably didn’t get that right then. The constants

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Sven Barth via fpc-pascal
Am Sa., 16. Feb. 2019, 15:34 hat Ryan Joseph geschrieben: > > > > On Feb 16, 2019, at 3:33 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > While you're at it, you should probably also ensure that internal error > 2014050904 does not trigger ;) > > That’s what

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Jonas Maebe
On 16/02/19 15:04, Ryan Joseph wrote: Btw, how does FPC generate internal errors numbers? I needed to add some errors myself and I didn’t know how to increment the counter. YearMonthDay00, YearMonthDay01, ... Jonas ___ fpc-pascal maillist -

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Ryan Joseph
> On Feb 16, 2019, at 3:33 AM, Sven Barth via fpc-pascal > wrote: > > While you're at it, you should probably also ensure that internal error > 2014050904 does not trigger ;) That’s what got my in the first place. I saw the internal error and made it not trigger but didn’t bother to check

Re: [fpc-pascal] Constants in generics tests

2019-02-16 Thread Sven Barth via fpc-pascal
Am 15.02.2019 um 23:00 schrieb Ryan Joseph: On Feb 15, 2019, at 4:19 PM, Sven Barth via fpc-pascal wrote: It could be that the method body is not generated. Look for generate_specialization_procs in pgenutil as that is what generates the bodies at the end of a unit (simplified). Really

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Ryan Joseph
> On Feb 15, 2019, at 4:19 PM, Sven Barth via fpc-pascal > wrote: > > It could be that the method body is not generated. Look for > generate_specialization_procs in pgenutil as that is what generates the > bodies at the end of a unit (simplified). > Really good catch Sven.

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Jeppe Johansen
Hi, Do you know why this doesn't work? type   TGPIO = class   public     class function ReadValue: NativeUInt; virtual; abstract;     class procedure SetValue(AValue: NativeUInt); virtual; abstract;     class function GetPin(const AIndex: NativeInt): boolean; virtual;   end;   generic

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Sven Barth via fpc-pascal
Am Fr., 15. Feb. 2019, 21:54 hat Ryan Joseph geschrieben: > > > > On Feb 15, 2019, at 2:11 PM, Ryan Joseph > wrote: > > > > Something with class functions in particular. Very strange it can’t find > the declaration. So never mind about submitting, I need to fix this now. :) > > I just looked

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Ryan Joseph
> On Feb 15, 2019, at 2:11 PM, Ryan Joseph wrote: > > Something with class functions in particular. Very strange it can’t find the > declaration. So never mind about submitting, I need to fix this now. :) I just looked over this and indeed I have no idea idea what happened. I suspect

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Sven Barth via fpc-pascal
Am Fr., 15. Feb. 2019, 20:58 hat Ryan Joseph geschrieben: > > > > On Feb 15, 2019, at 2:11 PM, Ryan Joseph > wrote: > > > > Also I just noticed that I’m getting warnings from the “U” constant > which is declared in the “strict private” section (Private const > "TTest$1.U" never used). That

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Ryan Joseph
> On Feb 15, 2019, at 2:11 PM, Ryan Joseph wrote: > > Also I just noticed that I’m getting warnings from the “U” constant which is > declared in the “strict private” section (Private const "TTest$1.U" never > used). That needs to be fixed also. Sven or some other compiler guy, do you > know

Re: [fpc-pascal] Constants in generics tests

2019-02-15 Thread Ryan Joseph
Good catch, I have no idea what broke or how that could have happened. I got it distilled down to this: type generic TTest = class class procedure DoThis; // <—— Forward declaration not solved "class DoThis;" end; class procedure TTest.DoThis; begin end; type ATest =

[fpc-pascal] Constants in generics tests

2019-02-15 Thread Ryan Joseph
Here’s the latest changes which fixed the constant type checking and includes some tests. Are the tests in the correct format? They are named tgenconst*.pp. https://github.com/genericptr/freepascal/tree/generic_constants For example: {%FAIL} {$mode objfpc} program tgenconst8; type

Re: [fpc-pascal] Constants in generics

2019-01-09 Thread Sven Barth via fpc-pascal
Am Mi., 9. Jan. 2019, 17:03 hat Ryan Joseph geschrieben: > > > > On Jan 8, 2019, at 3:49 PM, Benito van der Zander > wrote: > > > > that reminds me of https://bugs.freepascal.org/view.php?id=34232 > > In this case maybe generics should just not give range errors unless > they’re specialized?

Re: [fpc-pascal] Constants in generics

2019-01-09 Thread Ryan Joseph
> On Jan 8, 2019, at 3:49 PM, Benito van der Zander wrote: > > that reminds me of https://bugs.freepascal.org/view.php?id=34232 In this case maybe generics should just not give range errors unless they’re specialized? This bug and the problem I have are only for unspecialized generics. That

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Sven Barth via fpc-pascal
Am Di., 8. Jan. 2019, 23:49 hat Benito van der Zander geschrieben: > Hi, > > that reminds me of https://bugs.freepascal.org/view.php?id=34232 > Yes, that falls into the same category... Regards, Sven ___ fpc-pascal maillist -

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Benito van der Zander
Hi, that reminds me of https://bugs.freepascal.org/view.php?id=34232 Bye, Benito Am 08.01.19 um 23:28 schrieb Sven Barth via fpc-pascal: Am Di., 8. Jan. 2019, 21:01 hat Ryan Joseph mailto:r...@thealchemistguild.com>> geschrieben: I’ve made constants respect their proper definition

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Sven Barth via fpc-pascal
Am Di., 8. Jan. 2019, 21:01 hat Ryan Joseph geschrieben: > I’ve made constants respect their proper definition now so we can do range > checking but this broke some other things. For example there’s a range > check error with static arrays now because “U” has a value of 0 so 0-1 = -1: > > type >

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Ryan Joseph
I’ve made constants respect their proper definition now so we can do range checking but this broke some other things. For example there’s a range check error with static arrays now because “U” has a value of 0 so 0-1 = -1: type generic TList = record list: array[0..U-1]

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Jonas Maebe
On 08/01/19 17:34, Ryan Joseph wrote: I made a little utility function which works in most cases but I don’t think it’s correct and more importantly this function probably already exists in the compiler. function compare_orddef_by_range(param1,param2:torddef): boolean; var

Re: [fpc-pascal] Constants in generics

2019-01-08 Thread Ryan Joseph
Yesterday I discovered I wasn’t doing proper range checking for ordinal constants so for example, a generic with “const U: byte” could be specialized as <1000>. We want ordinal constants to respect range checks right? I made a little utility function which works in most cases but I don’t think

Re: [fpc-pascal] Constants in generics

2019-01-07 Thread Sven Barth via fpc-pascal
Am 07.01.2019 um 02:05 schrieb Ryan Joseph: I updated the github with the requested changes. Is that everything? I’ll submit a patch if so. https://github.com/genericptr/freepascal/tree/generic_constants Looks better. The following points remain: - make sure that you don't have any unrelated

Re: [fpc-pascal] Constants in generics

2019-01-07 Thread Ryan Joseph
> On Jan 6, 2019, at 11:32 PM, Ben Grasset wrote: > > Also, there's: > > pgenutil.pas(158,28) Warning: Class types "tenumdef" and "torddef" are not > related > > which breaks compilation because the compiler is built with -sew turned on if > you do it through the normal makefiles. I think

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ben Grasset
Also, there's: pgenutil.pas(158,28) Warning: Class types "tenumdef" and "torddef" are not related which breaks compilation because the compiler is built with -sew turned on if you do it through the normal makefiles. I think you need tests before you do a patch, also? (Unless you already have

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ben Grasset
You still have two C-style operator += instances in pgenutil.pas FYI, that don't compile with the default settings. On Sun, Jan 6, 2019 at 8:36 PM Ryan Joseph wrote: > I updated the github with the requested changes. Is that everything? I’ll > submit a patch if so. > >

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ryan Joseph
I updated the github with the requested changes. Is that everything? I’ll submit a patch if so. https://github.com/genericptr/freepascal/tree/generic_constants Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Sven Barth via fpc-pascal
Am So., 6. Jan. 2019, 22:38 hat Ryan Joseph geschrieben: > Since we introduced “const” keywords to generic params does it make sense > to use an optional “type” keyword also? That just occurred to me as > something worth discussing. No opinion either way except there’s a > inconsistency now

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Sven Barth via fpc-pascal
Am So., 6. Jan. 2019, 19:07 hat Ryan Joseph geschrieben: > Last question I have I think. > > Is this the best way to get "pretty name" string for a set? Having to loop > through the entire range of the set is not so great but I don’t see another > way. I feel like there should be some utility

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ryan Joseph
Since we introduced “const” keywords to generic params does it make sense to use an optional “type” keyword also? That just occurred to me as something worth discussing. No opinion either way except there’s a inconsistency now which may bother some people. generic TStuff = record end;

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ben Grasset
On Sun, Jan 6, 2019 at 4:23 PM Ryan Joseph wrote: > This is exactly the reason I added the feature, there’s no way to extend > static arrays otherwise! Beyond this one thing I have no idea what to use > them for. ;) > I've got a bunch of stuff in mind actually that I'm waiting on the "final"

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ryan Joseph
> On Jan 6, 2019, at 1:31 PM, Ben Grasset wrote: > > generic TStaticList = record > This is exactly the reason I added the feature, there’s no way to extend static arrays otherwise! Beyond this one thing I have no idea what to use them for. ;) Regards, Ryan Joseph

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ben Grasset
Just wanted to say, I've been playing around with Ryan's github branch that contains this functionality and I'm loving it! It really opens up a ton of interesting possibilities in general, and also a lot of potential for optimization via constant folding for generic containers that wasn't really

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ryan Joseph
Last question I have I think. Is this the best way to get "pretty name" string for a set? Having to loop through the entire range of the set is not so great but I don’t see another way. I feel like there should be some utility functions to get names for ord defs also but I just did a crude

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Ryan Joseph
> On Jan 6, 2019, at 1:28 AM, Sven Barth via fpc-pascal > wrote: > > Just think about it logically: B and C can't be anything else than const, so > why would we need to repeat it? I’m not saying anyone would actually write that generic but if it does appear what terminator is used? A more

Re: [fpc-pascal] Constants in generics

2019-01-06 Thread Sven Barth via fpc-pascal
Am Sa., 5. Jan. 2019, 22:57 hat Ryan Joseph geschrieben: > Here’s the new syntax requirements for const params which require types > and consts be separated by semicolons. > > Does TStuff2 need a ; between the two const params? Sven said consts must > follow ; or < but they’re both consts so I

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Ryan Joseph
Here’s the new syntax requirements for const params which require types and consts be separated by semicolons. Does TStuff2 need a ; between the two const params? Sven said consts must follow ; or < but they’re both consts so I thought I’d ask to make sure. type generic TStuff0 =

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Sven Barth via fpc-pascal
Am Sa., 5. Jan. 2019, 17:28 hat Ryan Joseph geschrieben: > > > > On Jan 5, 2019, at 1:18 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > I didn't design the original implementation, but the improvements for > the last five years or so have been mine.  > > > >

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Jonas Maebe
On 05/01/19 18:51, Ryan Joseph wrote: Given the new syntax requirements we talked about there needs to be a ; after T now. What error should be used if there isn’t a ; semicolon separator between types and consts? I just used a parser_e_illegal_expression for now.

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Ryan Joseph
Given the new syntax requirements we talked about there needs to be a ; after T now. What error should be used if there isn’t a ; semicolon separator between types and consts? I just used a parser_e_illegal_expression for now. generic TStuff = record Regards, Ryan Joseph

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Ryan Joseph
> On Jan 5, 2019, at 1:18 AM, Sven Barth via fpc-pascal > wrote: > > I didn't design the original implementation, but the improvements for the > last five years or so have been mine.  > > @Ryan: I can give it a try to rework the list from defs to syms and you can > then put your const

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread wkitty42
On 1/5/19 3:18 AM, Sven Barth via fpc-pascal wrote: Am Fr., 4. Jan. 2019, 21:11 hat geschrieben: On 1/4/19 1:47 PM, Ryan Joseph wrote: > Who designed the generics btw? unless i'm highly mistaken, you've been talking to them... they're quoted above, even ;) I didn't design the

Re: [fpc-pascal] Constants in generics

2019-01-05 Thread Sven Barth via fpc-pascal
Am Fr., 4. Jan. 2019, 21:11 hat geschrieben: > On 1/4/19 1:47 PM, Ryan Joseph wrote: > > > >> On Jan 3, 2019, at 11:11 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > >> > >> Fair enough. In that case support for constants in generics will have > to wait as well. 路‍ >

Re: [fpc-pascal] Constants in generics

2019-01-04 Thread wkitty42
On 1/4/19 1:47 PM, Ryan Joseph wrote: On Jan 3, 2019, at 11:11 PM, Sven Barth via fpc-pascal wrote: Fair enough. In that case support for constants in generics will have to wait as well. 路‍ Who designed the generics btw? unless i'm highly mistaken, you've been talking to them...

Re: [fpc-pascal] Constants in generics

2019-01-04 Thread Ryan Joseph
> On Jan 3, 2019, at 11:11 PM, Sven Barth via fpc-pascal > wrote: > > Fair enough. In that case support for constants in generics will have to wait > as well. 路‍ Who designed the generics btw? I’m not 100% certain that it’s even safe to change their design like this so it would be nice to

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Sven Barth via fpc-pascal
Am 03.01.2019 um 23:14 schrieb Ryan Joseph: On Jan 3, 2019, at 11:33 AM, Sven Barth via fpc-pascal wrote: The approach should be like this: - const is allowed at the start of the parameters or after a ";" - a parameter name is either followed by a ",", ";", ":" or ">" (that should already

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Ryan Joseph
> On Jan 3, 2019, at 11:33 AM, Sven Barth via fpc-pascal > wrote: > > The approach should be like this: > - const is allowed at the start of the parameters or after a ";" > - a parameter name is either followed by a ",", ";", ":" or ">" (that should > already be the case) > - a ":" is

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Sven Barth via fpc-pascal
Am Do., 3. Jan. 2019, 17:50 hat Ryan Joseph geschrieben: > > > > On Jan 3, 2019, at 6:20 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Correct. ";" separates different parameter types, "," separates those of > the same type. Though I agree with Mattias that

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Ryan Joseph
> On Jan 3, 2019, at 6:20 AM, Sven Barth via fpc-pascal > wrote: > > Correct. ";" separates different parameter types, "," separates those of the > same type. Though I agree with Mattias that "const T, const U" (with or > without ": Integer") should not work (but then "T, const U" should

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Sven Barth via fpc-pascal
Am Do., 3. Jan. 2019, 14:24 hat Alexander Shishkin via fpc-pascal < fpc-pascal@lists.freepascal.org> geschrieben: > 03.01.2019 15:45, Mattias Gaertner via fpc-pascal пишет: > > On Thu, 3 Jan 2019 14:58:00 +0300 > > Alexander Shishkin via fpc-pascal > > wrote: > > > >> [...] > >> This is OK (both

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Alexander Shishkin via fpc-pascal
03.01.2019 15:45, Mattias Gaertner via fpc-pascal пишет: On Thu, 3 Jan 2019 14:58:00 +0300 Alexander Shishkin via fpc-pascal wrote: [...] This is OK (both T and U are integer): generic TMyRecord1 = record end; That is inconsistent to normal Pascal arguments. Name[, Name ...][:type] Isn't

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Sven Barth via fpc-pascal
Am Do., 3. Jan. 2019, 12:58 hat Alexander Shishkin via fpc-pascal < fpc-pascal@lists.freepascal.org> geschrieben: > 03.01.2019 6:32, Ryan Joseph пишет: > > > > > >> On Jan 2, 2019, at 8:25 PM, Alexander Shishkin via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > >> > >> This is not

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Mattias Gaertner via fpc-pascal
On Thu, 3 Jan 2019 14:58:00 +0300 Alexander Shishkin via fpc-pascal wrote: >[...] > This is OK (both T and U are integer): > generic TMyRecord1 = record end; That is inconsistent to normal Pascal arguments. Name[, Name ...][:type] Isn't it? Mattias

Re: [fpc-pascal] Constants in generics

2019-01-03 Thread Alexander Shishkin via fpc-pascal
03.01.2019 6:32, Ryan Joseph пишет: On Jan 2, 2019, at 8:25 PM, Alexander Shishkin via fpc-pascal wrote: This is not consistent with constraints. Should be ";" after T. And what about following examples? The semicolon is only needed following a generic parameter which is constrained.

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Ryan Joseph
> On Jan 2, 2019, at 8:25 PM, Alexander Shishkin via fpc-pascal > wrote: > > This is not consistent with constraints. Should be ";" after T. > > And what about following examples? > The semicolon is only needed following a generic parameter which is constrained. This was the normal

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Alexander Shishkin via fpc-pascal
03.01.2019 4:29, Ryan Joseph пишет: type generic TMyRecord_Int = record end; This is not consistent with constraints. Should be ";" after T. And what about following examples? type generic TMyRecord1 = record end; type generic TMyRecord2 = record

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Ryan Joseph
> On Jan 2, 2019, at 5:52 PM, Alexander Shishkin via fpc-pascal > wrote: > > Thanks, now I`ve lost is a discussion again. What is the decision about > syntax? Is "const" prefix and/or ": type" suffix required? const is required but the type is not. Here’s a test for all the const types

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Ryan Joseph
> On Jan 2, 2019, at 3:13 PM, Alexander Shishkin via fpc-pascal > wrote: > > I`d like to see constant parameter to be constrained with type > > type > generic TList = record > list: array[0..U-1] of T; > function capacity: integer; > end; This is the

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Alexander Shishkin via fpc-pascal
Thanks, now I`ve lost is a discussion again. What is the decision about syntax? Is "const" prefix and/or ": type" suffix required? generic TList1 = class var data: array[0..U] of T; end; generic TList2 = class var data: array[0..U] of T; end; generic TLis3 = class var data: array[0..U]

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Sven Barth via fpc-pascal
Am Mi., 2. Jan. 2019, 23:41 hat Alexander Shishkin via fpc-pascal < fpc-pascal@lists.freepascal.org> geschrieben: > 06.11.2018 10:13, Ryan Joseph пишет: > > > > program generic_constants; > > > > type > > generic TList = record > > list: array[0..U-1] of T; > >

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Alexander Shishkin via fpc-pascal
06.11.2018 10:13, Ryan Joseph пишет: program generic_constants; type generic TList = record list: array[0..U-1] of T; function capacity: integer; end; I`d like to see constant parameter to be constrained with type type generic TList

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread denisgolovan
Well, I'll wait then.That's definitely nice to have feature.02.01.2019, 16:33, "Sven Barth via fpc-pascal" :Am Mi., 2. Jan. 2019, 11:20 hat denisgolovan geschrieben:Hi, allCould someone confirm this functionality is merged into trunk? I mean constants in generics.I can

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread Sven Barth via fpc-pascal
Am Mi., 2. Jan. 2019, 11:20 hat denisgolovan geschrieben: > Hi, all > > Could someone confirm this functionality is merged into trunk? I mean > constants in generics. > I can confirm that it is not integrated in trunk. Regards, Sven ___ fpc-pascal

Re: [fpc-pascal] Constants in generics

2019-01-02 Thread denisgolovan
Hi, allCould someone confirm this functionality is merged into trunk? I mean constants in generics.29.11.2018, 05:24, "Ryan Joseph" : On Nov 29, 2018, at 5:15 AM, Sven Barth via fpc-pascal wrote: Looks better. The next thing to nuke is the tgenericparamdef. The

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Ryan Joseph
> On Nov 28, 2018, at 11:25 PM, Sven Barth via fpc-pascal > wrote: > > You're not wrong, but a type alias is definitely the wrong way. > But that is a completely different topic, one that I'm not willing to discuss > right now, aside from "we don't support something like that”. Ok, maybe

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Ryan Joseph
> On Nov 29, 2018, at 5:15 AM, Sven Barth via fpc-pascal > wrote: > > Looks better. > The next thing to nuke is the tgenericparamdef. The parameters stored in > tdef.genericparas are the parameter symbols, so there should be no need for > defs. If necessary some of the code in pgenutil (and

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Sven Barth via fpc-pascal
Am 27.11.2018 um 11:35 schrieb Sven Barth: Am Di., 27. Nov. 2018, 08:18 hat Ryan Joseph mailto:r...@thealchemistguild.com>> geschrieben: > On Nov 27, 2018, at 4:59 AM, Sven Barth via fpc-pascal mailto:fpc-pascal@lists.freepascal.org>> wrote: > > Best check again once you've

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Sven Barth via fpc-pascal
Am Mi., 28. Nov. 2018, 15:27 hat Ryan Joseph geschrieben: > > > > On Nov 28, 2018, at 7:26 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Because that is not supposed to work. Generic routines are *routines*, > not types. You can't define aliases for routines

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Ryan Joseph
> On Nov 28, 2018, at 7:26 PM, Sven Barth via fpc-pascal > wrote: > > Because that is not supposed to work. Generic routines are *routines*, not > types. You can't define aliases for routines either, not to mention the > problems with scoping as generic methods exist as well. It seems

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Sven Barth via fpc-pascal
Am Mi., 28. Nov. 2018, 09:41 hat Ryan Joseph geschrieben: > I just noticed I sent this to the wrong person and the list never saw it > so I’m sending it again. I feel like I should try to fix it while I’ve got > my eyes on the generics code before I forget. > > Is there a reason it’s not

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Ryan Joseph
> On Nov 27, 2018, at 11:07 PM, Sven Barth via fpc-pascal > wrote: > > Does it also work correctly if you change the constant and then recompile? > The same if the specialization is inside another unit used by the program? > It appears to work. I’ll make a proper test suite once we have

Re: [fpc-pascal] Constants in generics

2018-11-28 Thread Ryan Joseph
I just noticed I sent this to the wrong person and the list never saw it so I’m sending it again. I feel like I should try to fix it while I’ve got my eyes on the generics code before I forget. Is there a reason it’s not implemented yet? In theory you should be able to specialize a function

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Sven Barth via fpc-pascal
Am Di., 27. Nov. 2018, 15:08 hat Ryan Joseph geschrieben: > > You did read the part about the generic and the specialization being > located in two different units?  > > Oops. This still works so I guess it’s ok. > > program gc_ppu; > uses > gc_types_unit; > > var > a:

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Ryan Joseph
> On Nov 27, 2018, at 8:11 PM, Sven Barth via fpc-pascal > wrote: > > We can add a new message that says "type id or untyped constant expected". > But if it correctly errors right now, we can leave it be for now. > Fine by me. > You did read the part about the generic and the

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Sven Barth via fpc-pascal
Am Di., 27. Nov. 2018, 14:00 hat Ryan Joseph geschrieben: > > > > On Nov 27, 2018, at 5:35 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > 1) kSomeDays is a typed const so I get a load node instead of > tsetconstnode, which I need to need to know in order to

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Sven Barth via fpc-pascal
Am Di., 27. Nov. 2018, 12:03 hat Mattias Gaertner via fpc-pascal < fpc-pascal@lists.freepascal.org> geschrieben: > On Tue, 27 Nov 2018 11:35:22 +0100 > Sven Barth via fpc-pascal wrote: > > >[...] > > > const > > > kSomeDays:TDays = [Mon, Wed]; > >[...] > > The difference between typed

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Ryan Joseph
> On Nov 27, 2018, at 5:35 PM, Sven Barth via fpc-pascal > wrote: > > 1) kSomeDays is a typed const so I get a load node instead of tsetconstnode, > which I need to need to know in order to make the name string. See the TODO’s > in tgenericparamdef.create. > > type > TDay = (Mon,

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Sven Barth via fpc-pascal
Am Di., 27. Nov. 2018, 08:18 hat Ryan Joseph geschrieben: > > > > On Nov 27, 2018, at 4:59 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Best check again once you've done the switch to tconstsym for constants. > :) > > > > I made most of the changes you

Re: [fpc-pascal] Constants in generics

2018-11-27 Thread Ryan Joseph
> On Nov 27, 2018, at 2:25 PM, denisgolovan wrote: > > Hi > > Sorry for breaking in, but I'd like to know if this functionality supports > specializing generic functions with const parameters? > > BR, > Denis Here’s my test which seems to be working. program gc_procs; generic procedure

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread denisgolovan
> Here’s my test which seems to be working. > > program gc_procs; > > generic procedure DoThis(msg:string = U); > begin > writeln(msg, ' ',sizeof(T), ' ', U); > end; > > begin > specialize DoThis('hello world’); // prints "hello world 4 foo" > specialize DoThis; // prints “foo 4 foo" > end.

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread denisgolovan
Hi Sorry for breaking in, but I'd like to know if this functionality supports specializing generic functions with const parameters? BR, Denis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Ryan Joseph
> On Nov 27, 2018, at 4:59 AM, Sven Barth via fpc-pascal > wrote: > > Best check again once you've done the switch to tconstsym for constants. :) > I made most of the changes you mentioned so please look. Including the constsyms didn’t break anything and helped to clean up the code. I

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Sven Barth via fpc-pascal
Am Mo., 26. Nov. 2018, 15:47 hat Ryan Joseph geschrieben: > > > > On Nov 26, 2018, at 8:18 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > You don't need to manually check for U. The parser will find U in the > symbol table of the TMyClass generic and then a

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Ryan Joseph
> On Nov 26, 2018, at 8:18 PM, Sven Barth via fpc-pascal > wrote: > > You don't need to manually check for U. The parser will find U in the symbol > table of the TMyClass generic and then a list containing the parameters will > be generated and passed to

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Sven Barth via fpc-pascal
Am Mo., 26. Nov. 2018, 12:14 hat Ryan Joseph geschrieben: > > > > On Nov 26, 2018, at 5:16 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Am Mo., 26. Nov. 2018, 10:46 hat Ryan Joseph > geschrieben: > > > > > > > On Nov 26, 2018, at 12:09 AM, Sven Barth via

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Ryan Joseph
> On Nov 26, 2018, at 5:16 PM, Sven Barth via fpc-pascal > wrote: > > Am Mo., 26. Nov. 2018, 10:46 hat Ryan Joseph > geschrieben: > > > > On Nov 26, 2018, at 12:09 AM, Sven Barth via fpc-pascal > > wrote: > > > > - your pretty name is wrong; the pretty name for a specialization with >

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Sven Barth via fpc-pascal
Am Mo., 26. Nov. 2018, 10:46 hat Ryan Joseph geschrieben: > > > > On Nov 26, 2018, at 12:09 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > - your pretty name is wrong; the pretty name for a specialization with > constants should be "TSomeGeneric", not >

Re: [fpc-pascal] Constants in generics

2018-11-26 Thread Ryan Joseph
> On Nov 26, 2018, at 12:09 AM, Sven Barth via fpc-pascal > wrote: > > - your pretty name is wrong; the pretty name for a specialization with > constants should be "TSomeGeneric", not > "TSomeGeneric" as it would be now I’ll change the # prefix for const params but the unit prefix was not

Re: [fpc-pascal] Constants in generics

2018-11-25 Thread Sven Barth via fpc-pascal
Am 14.11.2018 um 03:25 schrieb Ryan Joseph: I think I have this done except for cleanup. Here’s the status: - Integer,string,real,set and nil constant for parameters. - Consts can have type restrictions which correspond to the above types. - Const can be assigned to from generic const params. -

Re: [fpc-pascal] Constants in generics

2018-11-13 Thread Ryan Joseph
I think I have this done except for cleanup. Here’s the status: - Integer,string,real,set and nil constant for parameters. - Consts can have type restrictions which correspond to the above types. - Const can be assigned to from generic const params. - PPU loading. Technical compiler issues: - I

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Ben Grasset
On Thu, Nov 8, 2018 at 11:50 PM Ryan Joseph wrote: > Question: should other consts besides integers be allowed? I don’t think > it makes sense personally to use strings, floats or sets but maybe I’m > wrong. > As a daily FPC user there's nothing I find more annoying than compiler restrictions

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Sven Barth via fpc-pascal
Am Sa., 10. Nov. 2018, 14:47 hat Ryan Joseph geschrieben: > > > > On Nov 10, 2018, at 7:22 PM, Florian Klämpfl > wrote: > > > > If you "export" a generic taking a const from a unit, this info has to > be stored in the ppu. > > Can you show a test case I could use to see where this is triggered

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Ryan Joseph
> On Nov 10, 2018, at 7:22 PM, Florian Klämpfl wrote: > > If you "export" a generic taking a const from a unit, this info has to be > stored in the ppu. Can you show a test case I could use to see where this is triggered in the compiler? I don’t even know where to begin looking. Regards,

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Florian Klämpfl
Am 10.11.2018 um 13:20 schrieb Ryan Joseph: >>> - the compiler contains already a type called tgenericdef >>> >>> I think I changed that name in the last commit. Btw I made all those types >>> because I didn’t want to populate the main types like ttypesym with extra >>> bytes but I don’t

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Ryan Joseph
> On Nov 10, 2018, at 7:16 PM, Florian Klämpfl wrote: > > This does not prevent you from creating proper commits, especially as the > patch series from github could be easily > applied later on to fpc's main repository. I’ll assume these commits could be public some day then. I originally

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Florian Klämpfl
Am 09.11.2018 um 03:13 schrieb Ryan Joseph: > > >> On Nov 9, 2018, at 4:28 AM, Florian Klämpfl wrote: >> >> I like the idea of const in generics, but it needs serious cleanup when it's >> working: >> - commit messages like "first commit" are useless > > Those are for github so I could share

Re: [fpc-pascal] Constants in generics

2018-11-10 Thread Florian Klämpfl
Am 09.11.2018 um 05:20 schrieb Ryan Joseph: > > >> On Nov 9, 2018, at 4:28 AM, Florian Klämpfl wrote: >> >> I like the idea of const in generics, but it needs serious cleanup when it's >> working: > > Question: should other consts besides integers be allowed? I don’t think it > makes sense

Re: [fpc-pascal] Constants in generics

2018-11-08 Thread Sven Barth via fpc-pascal
Am Fr., 9. Nov. 2018, 03:44 hat Ryan Joseph geschrieben: > > > > On Nov 9, 2018, at 4:28 AM, Florian Klämpfl > wrote: > > > > I like the idea of const in generics, but it needs serious cleanup when > it's working: > > - commit messages like "first commit" are useless > > Those are for github so

Re: [fpc-pascal] Constants in generics

2018-11-08 Thread Ryan Joseph
> On Nov 9, 2018, at 4:28 AM, Florian Klämpfl wrote: > > I like the idea of const in generics, but it needs serious cleanup when it's > working: Question: should other consts besides integers be allowed? I don’t think it makes sense personally to use strings, floats or sets but maybe I’m

  1   2   >