Re: [fpc-devel] Typed constants

2019-03-18 Thread Sven Barth via fpc-devel
Ryan Joseph schrieb am Mo., 18. März 2019, 00:50: > I just realized that typed constants exist and may need to be supported as > constants for generics but I’ve never used them myself (not sure when they > were introduced). > > First test gives an error so it makes me wonder if they’re buggy and

Re: [fpc-devel] Typed constants

2019-03-17 Thread J. Gareth Moreton
I've actually had this problem myself - sometimes it's quite critical as well because you might want things like const   Pi: Double = 3.14159265359;   HalfPi: Double = Pi / 2;  TwoPi: Double = 2 * Pi; Will return the illegal expression error as well, even if Pi is fully declared elsewhere,

[fpc-devel] Typed constants

2019-03-17 Thread Ryan Joseph
I just realized that typed constants exist and may need to be supported as constants for generics but I’ve never used them myself (not sure when they were introduced). First test gives an error so it makes me wonder if they’re buggy and should be allowed for generics. Should they? const

Re: [fpc-devel] Typed constants question

2018-07-28 Thread J. Gareth Moreton
Given I want to be conservative with pure functions so it's near-impossible to write something that breaks the compiler or cause unexpected behaviour in the compiled binary, I'll treat the accessing of such a constant as "impure" for reasons of safety.  My work-in-progress already detects

Re: [fpc-devel] Typed constants question

2018-07-28 Thread Marco van de Voort
In our previous episode, J. Gareth Moreton said: > For a more fundamental question... why are typed and untyped constants > treated differently? Turbo Pascal allowed to write them, depending on a switch. $J. Delphi adds {$writeableconst on} iirc. But even when this is off, you can't be sure

[fpc-devel] Typed constants question

2018-07-28 Thread J. Gareth Moreton
So I have a question about constants. While programming pure functions, I noticed that typed and untyped constants are treated differently.  Something like "const Pi = 3.14159", even if declared outside of the current function, is propagated directly in expressions - the node construction shows