Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Ben Grasset
On Tue, Jul 16, 2019 at 8:35 AM Michael Van Canneyt wrote: > 2. The Low(T) does not work, as there is no way to tell Delphi that T must > be an enum. > Hmm, I guess it makes sense Delphi wouldn't allow the "Low", based on other Delphi generics behavior (more like C#, whereas FPC is more like

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Sven Barth via fpc-devel
Michael Van Canneyt schrieb am Di., 16. Juli 2019, 16:31: > > > On Tue, 16 Jul 2019, Ben Grasset wrote: > > > On Tue, Jul 16, 2019 at 5:28 AM Sven Barth via fpc-devel < > > fpc-devel@lists.freepascal.org> wrote: > > > >> The output will then be two different addresses, thus showing that the > >>

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Michael Van Canneyt
On Tue, 16 Jul 2019, Ben Grasset wrote: On Tue, Jul 16, 2019 at 5:28 AM Sven Barth via fpc-devel < fpc-devel@lists.freepascal.org> wrote: The output will then be two different addresses, thus showing that the code had been generated twice. However the compiler/linker is good at leaving out

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Ben Grasset
On Tue, Jul 16, 2019 at 5:28 AM Sven Barth via fpc-devel < fpc-devel@lists.freepascal.org> wrote: > The output will then be two different addresses, thus showing that the > code had been generated twice. > > However the compiler/linker is good at leaving out unused code and in this > case only

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Michael Van Canneyt
On Sat, 13 Jul 2019, Ben Grasset wrote: On Sat, Jul 13, 2019 at 2:37 PM Ondrej Pokorny wrote: I do exactly the same - check the low/high bounds in a type helper :) Yes, and I am tired of typing it as well :) You can pretty easily write a generic function that will work on pretty much

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Sven Barth via fpc-devel
Ben Grasset schrieb am Mo., 15. Juli 2019, 23:48: > On Mon, Jul 15, 2019 at 5:23 PM Sven Barth via fpc-devel < > fpc-devel@lists.freepascal.org> wrote: > >> That is exactly what is happening if you have a specialization in >> multiple units that don't know about each other. >> > > At what point

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Sven Barth via fpc-devel
Ben Grasset schrieb am Di., 16. Juli 2019, 00:13: > On Mon, Jul 15, 2019 at 5:50 PM Michael Van Canneyt < > mich...@freepascal.org> wrote: > >> As far as I know, they are not. I believe that when specializing, the >> compiler checks if an identical specialization is in scope: >> if so, it uses

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Sven Barth via fpc-devel
Michael Van Canneyt schrieb am Mo., 15. Juli 2019, 23:50: > > > On Mon, 15 Jul 2019, Ben Grasset wrote: > > > On Mon, Jul 15, 2019 at 5:23 PM Sven Barth via fpc-devel < > > fpc-devel@lists.freepascal.org> wrote: > > > >> That is exactly what is happening if you have a specialization in >

Re: [fpc-devel] [Suggestion] Enumeration range-check intrinsic

2019-07-16 Thread Kai Burghardt
Nihao, On Sat, Jul 13, 2019 at 01:52:46PM +0200, Michael Van Canneyt wrote: > On Sat, 13 Jul 2019, Jonas Maebe wrote: > > On 13/07/2019 13:28, J. Gareth Moreton wrote: > > [...] > > > > Declare your enumation types so that the lowest and highest valid value > > comprise the lowest and highest