Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-28 Thread Benito van der Zander
Hi, Also assume you have a record and a hashmap that stores them. Now you add a string to the record which turns it into a managed one and suddenly your code will no longer work, probably resulting in subtle bugs or memory leaks. That's /not/ what should happen for merely adding a string.

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-27 Thread Sven Barth via fpc-devel
Ryan Joseph via fpc-devel schrieb am Mo., 27. Apr. 2020, 18:28: > I think constants in generics may be the only way to create dynamically > sized types at compile time (via static arrays). That seems like a really > narrow usage but it opens a lot of doors most of us have probably never > thought

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-27 Thread Ryan Joseph via fpc-devel
I think constants in generics may be the only way to create dynamically sized types at compile time (via static arrays). That seems like a really narrow usage but it opens a lot of doors most of us have probably never thought about. I suspect in time more good usages will be discovered. Regards

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Sven Barth via fpc-devel
Am 26.04.2020 um 23:42 schrieb Benito van der Zander: Hi Sven, It's not that simple. In principle you're right that the compiler could try to merge more implementations, but this does not depend on the declaration of the generic, but the use of the parameter types. I mostly use generics fo

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Kai Burghardt
Hey folks! On Sun, Apr 26, 2020 at 03:09:43PM +0700, Ryan Joseph via fpc-devel wrote: > It was meant for a pretty narrow use of array types. [...] If so, can I finally have my Extended Pascal schemata? https://wiki.freepascal.org/Extended_Pascal#Schemata_.28not_yet_implemented.29 It's basically

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Marco van de Voort
Op 2020-04-26 om 11:48 schreef Sven Barth via fpc-devel: Jeppe had provided a potential usecase on the core mailing list in October '18. His example is not useable as-is, but to give you an idea:  As the compiler can inline all this, the writing of maintainable, hardware agnostic frameworks

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Benito van der Zander
Hi Sven, It's not that simple. In principle you're right that the compiler could try to merge more implementations, but this does not depend on the declaration of the generic, but the use of the parameter types. I mostly use generics for containers, especially hashmaps. They only stores th

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Marco van de Voort
Op 2020-04-26 om 11:02 schreef Michael Van Canneyt: As the original author, can you say something about the intended use of this feature ? It was meant for a pretty narrow use of array types. If I knew how much work it would be to implement I probably would have not done it. :P I personall

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Ben Grasset via fpc-devel
On Sun, Apr 26, 2020 at 4:08 AM Anthony Walter via fpc-devel < fpc-devel@lists.freepascal.org> wrote: > Thank you Ryan and Sven. Your work is much appreciated as usual. > > However, Michael beat me to it in asking how this feature is useful. I am > sure there might be use cases, but for right now

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Ben Grasset via fpc-devel
On Sat, Apr 25, 2020 at 6:14 PM Sven Barth via fpc-devel < fpc-devel@lists.freepascal.org> wrote: > The Free Pascal team is happy to announce the addition of a new language > feature: constant parameters for generics. > YES! This is fantastic news. ___

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Sven Barth via fpc-devel
Am 26.04.2020 um 14:01 schrieb Benito van der Zander: Hi, perhaps it could be used to merge specializations (if fpc cannot do that on its own): Like when you have a hashmap THashMap, and need three specializations: THashMap THashMap THashMap It is basically three times the same hashmap,

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Benito van der Zander
Hi, perhaps it could be used to merge specializations (if fpc cannot do that on its own): Like when you have a hashmap THashMap, and need three specializations: THashMap THashMap THashMap It is basically three times the same hashmap, but if fpc does not detect that, it might generate th

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Sven Barth via fpc-devel
Am 26.04.2020 um 09:38 schrieb Michael Van Canneyt: On Sun, 26 Apr 2020, Ryan Joseph via fpc-devel wrote: On Apr 26, 2020, at 5:13 AM, Sven Barth via fpc-devel wrote: The Free Pascal team is happy to announce the addition of a new language feature: constant parameters for generics. E

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Ryan Joseph via fpc-devel
> On Apr 26, 2020, at 4:02 PM, Michael Van Canneyt > wrote: > > Fixed-length arrays are the only practical use I can think of. I think you're right. Here's what I'll say next time: They're for composing types of dynamic size at compile time. :) Regards, Ryan Joseph

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Florian Klaempfl
Am 26.04.2020 um 11:02 schrieb Michael Van Canneyt: On Sun, 26 Apr 2020, Ryan Joseph via fpc-devel wrote: On Apr 26, 2020, at 2:38 PM, Michael Van Canneyt wrote: As the original author, can you say something about the intended use of this feature ? It was meant for a pretty narrow us

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Michael Van Canneyt
On Sun, 26 Apr 2020, Ryan Joseph via fpc-devel wrote: On Apr 26, 2020, at 2:38 PM, Michael Van Canneyt wrote: As the original author, can you say something about the intended use of this feature ? It was meant for a pretty narrow use of array types. If I knew how much work it would be

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread gabor
W dniu 2020-04-26 o 09:38, Michael Van Canneyt pisze: Sven gave some examples, and they show how it works, but from his examples I don't see the point of this feature. Michael. It can be quite useful. You can do something similar (I hope): https://sourceforge.net/p/ultravnc/code/HEAD/tree/Ult

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Ryan Joseph via fpc-devel
> On Apr 26, 2020, at 2:38 PM, Michael Van Canneyt > wrote: > > As the original author, can you say something about the intended use of this > feature ? It was meant for a pretty narrow use of array types. If I knew how much work it would be to implement I probably would have not done it. :

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Anthony Walter via fpc-devel
Thank you Ryan and Sven. Your work is much appreciated as usual. However, Michael beat me to it in asking how this feature is useful. I am sure there might be use cases, but for right now I am coming up without any real advantages. Could anyone with better insight than me please explain? _

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Michael Van Canneyt
On Sun, 26 Apr 2020, Ryan Joseph via fpc-devel wrote: On Apr 26, 2020, at 5:13 AM, Sven Barth via fpc-devel wrote: The Free Pascal team is happy to announce the addition of a new language feature: constant parameters for generics. Excellent! Thanks for getting this merged. It was a lo

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-25 Thread Ryan Joseph via fpc-devel
> On Apr 26, 2020, at 5:13 AM, Sven Barth via fpc-devel > wrote: > > The Free Pascal team is happy to announce the addition of a new language > feature: constant parameters for generics. Excellent! Thanks for getting this merged. It was a long battle but it's finally over. ;) Regards,