Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread russeld
Pascal allows type declarations at the procedure level, so you could use type aliases to reduce your typing and still have code completion: procedure foo(); type SVK = NSSomeLongNameOfSomethingValueKey; var a: SVK; begin a := SVK.some_key_value; end; If you tried to use SVK elsewhere an

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Benito van der Zander
Hi Fpc-pascal Users, I simply rely on my IDE (Lazarus, Visual Studio)  to complete long identifier names for me so that I don't have to. *shrugs*  but you still need to read the identifiers and when they are too long, that takes time, too How does that look? No idea how it looked, but

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > > Having to decide a variable is scoped or not when it is declared is not the > > most ideal solution anyway. Logically you would decide that when creating > > the scope, iow when importing, like in Modula2 or (afaik also) Extended > > Pascal. > > How

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Bernd Oppolzer
Am 21.02.2018 um 16:29 schrieb Ryan Joseph: On Feb 21, 2018, at 10:13 PM, Michael Van Canneyt wrote: You lose an important type safety if you replace them with constants. I like enums also but you can imagine when they were proposed the compiler teams probably

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 10:13 PM, Michael Van Canneyt > wrote: > > You lose an important type safety if you replace them with constants. I like enums also but you can imagine when they were proposed the compiler teams probably compared them to constants and decided if

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 10:18 PM, Marco van de Voort wrote: > > Having to decide a variable is scoped or not when it is declared is not the > most ideal solution anyway. Logically you would decide that when creating > the scope, iow when importing, like in Modula2 or (afaik

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > Adding compiler features is a slippery slope and I have no idea where to > draw lines. Scoped enums aren?t necessary and in fact enums in general > could be replaced with constants easily enough so that feature was > probably debated at some point

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Ryan Joseph wrote: On Feb 21, 2018, at 5:16 PM, Sven Barth via fpc-pascal wrote: I simply rely on my IDE (Lazarus, Visual Studio) to complete long identifier names for me so that I don't have to. *shrugs* Sure enough it’s not a

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 5:16 PM, Sven Barth via fpc-pascal > wrote: > > I simply rely on my IDE (Lazarus, Visual Studio) to complete long identifier > names for me so that I don't have to. *shrugs* Sure enough it’s not a pressing matter by any means but I

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Martok
Am 21.02.2018 um 10:45 schrieb Michael Van Canneyt: > I was waiting for this reply from you. You didn't disappoint ;) Got an image to maintain ;-) Took me long enough to come up with that actually fairly simple workaround, might as well save others the trouble. That stuff is like "bad keming", I

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread wkitty42
On 02/21/2018 05:16 AM, Sven Barth via fpc-pascal wrote: I simply rely on my IDE (Lazarus, Visual Studio) to complete long identifier names for me so that I don't have to. *shrugs* exactly my thoughts, too... -- NOTE: No off-list assistance is given without prior approval. *Please

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Sven Barth via fpc-pascal wrote: Am 21.02.2018 09:48 schrieb "Ryan Joseph" : On Feb 21, 2018, at 2:57 PM, Michael Van Canneyt wrote: The job of the compiler is to create correct code. Not to ensure you write

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Sven Barth via fpc-pascal
Am 21.02.2018 09:48 schrieb "Ryan Joseph" : > On Feb 21, 2018, at 2:57 PM, Michael Van Canneyt wrote: > > The job of the compiler is to create correct code. Not to ensure you write readable code. Every feature that is introduced > offers more

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Martok wrote: I doubt that many would be using scopedenums for that. Isn't that what they're for? {$SCOPEDENUMS ON} type TTileSortingFlag = (Static, Ramp, Ignore, Particle, Floor,

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Mattias Gaertner
On Wed, 21 Feb 2018 16:14:13 +0700 Ryan Joseph wrote: >[...] > {$scopedenums on} > type > TTileSortingFlag = (Static, > Ramp, > Ignore, > Particle, >

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Martok
> I doubt that many would be using scopedenums for that. Isn't that what they're for? {$SCOPEDENUMS ON} type TTileSortingFlag = (Static, Ramp, Ignore, Particle, Floor, Flat,

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Ryan Joseph wrote: On Feb 21, 2018, at 4:09 PM, Mattias Gaertner wrote: I doubt that many would be using scopedenums for that. why not? Scoped enums did clean that up a little but still lots of extra typing during assignments and

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 4:09 PM, Mattias Gaertner > wrote: > > I doubt that many would be using scopedenums for that. why not? Scoped enums did clean that up a little but still lots of extra typing during assignments and parameters. That compared to the previous is

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Mattias Gaertner
On Wed, 21 Feb 2018 15:58:12 +0700 Ryan Joseph wrote: >[...] > type > TTileSortingFlag = (kTileSortingStatic, > kTileSortingRamp, > kTileSortingIgnore, >

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 3:45 PM, Mattias Gaertner > wrote: > > I think this would be confusing: > > {$scopedenums on} > type > TMyType = (A, B, C); > {$scopedenums off} > var > A: integer; > > procedure DoThis (t: TMyType; i: integer); > begin > end; > >

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Ryan Joseph
> On Feb 21, 2018, at 2:57 PM, Michael Van Canneyt > wrote: > > The job of the compiler is to create correct code. Not to ensure you write > readable code. Every feature that is introduced > offers more scope for abuse (generics jump to mind). I think you may change

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-21 Thread Mattias Gaertner
On Wed, 21 Feb 2018 09:38:17 +0700 Ryan Joseph wrote: >[...]Doesn’t the compiler know the type and can infer “A” is relative to the >scoped enum? I understand there’s a possibility for name conflicts but you >could just use the full name in that case. I think this

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Ryan Joseph wrote: On Feb 21, 2018, at 1:54 PM, Michael Van Canneyt wrote: So this is "as designed". If you want to be able to write A, don't use scoped enums. I got the idea from Swift (one of the things it does right) and it’s really nice

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Ryan Joseph
> On Feb 21, 2018, at 2:01 PM, Sven Barth via fpc-pascal > wrote: > > The compiler does not know the type of the parameter, because overload > selection occurs only after all parameters have been parsed. So during > parsing the compiler would not know from

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Ryan Joseph
> On Feb 21, 2018, at 1:54 PM, Michael Van Canneyt > wrote: > > So this is "as designed". If you want to be able to write A, don't use > scoped enums. I got the idea from Swift (one of the things it does right) and it’s really nice to be able say "this = .value”

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Sven Barth via fpc-pascal
Am 21.02.2018 04:09 schrieb "Ryan Joseph" : Is this a missing feature or do you need to enable it or something? There is none. The compiler does not know the type of the parameter, because overload selection occurs only after all parameters have been parsed. So

Re: [fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Michael Van Canneyt
On Wed, 21 Feb 2018, Ryan Joseph wrote: I just learned FPC has scoped enums, which is nice, but they lack what you could call “relative inference” based on the type being passed. In the example below the parameter “t” is TMyType but passing “A” doesn’t work. Doesn’t the compiler know the

[fpc-pascal] Scoped enums and inferred types

2018-02-20 Thread Ryan Joseph
I just learned FPC has scoped enums, which is nice, but they lack what you could call “relative inference” based on the type being passed. In the example below the parameter “t” is TMyType but passing “A” doesn’t work. Doesn’t the compiler know the type and can infer “A” is relative to the