Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Florian Klämpfl
Am 25.02.2018 um 13:31 schrieb Florian Klämpfl: > Am 25.02.2018 um 13:28 schrieb Giuliano Colla: >> Il 25/02/2018 13:15, Sven Barth via fpc-devel ha scritto: >> >>> Yes, we definitely feel good about this, because we don't *want* parameter >>> support in FPC's macro >>> handling. >> >> Maybe I'm

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Mark Morgan Lloyd
On 25/02/18 18:15, Giuliano Colla wrote: Il 25/02/2018 18:34, Florian Klämpfl ha scritto: http://www.gnu-pascal.de/gpc/Preprocessor.html, nobody prevents people to run a preprocessor before> FPC gets the code. That's a constructive suggestion. Easily put in the makefile [DUCKS] :-) -- Mark

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 5:34 PM, Michael Van Canneyt wrote: >> So, would it be possible to have an overloaded Abs(V: Variant): >> Variant; function in the variants unit? > > > I advise against it. > > S : String; > > begin > S:='My very nice string'; > S:=Abs(S); >

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Sven Barth via fpc-devel
Am 25.02.2018 12:14 schrieb "Mark Morgan Lloyd" < markmll.fpc-de...@telemetry.co.uk>: On 25/02/18 10:30, Florian Klämpfl wrote: > Am 25.02.2018 um 11:12 schrieb Mark Morgan Lloyd:> On 25/02/18 02:15, Ozz > Nixon wrote:>> {$MACRO ON}>> {$DEFINE _CTASSERT(X,Y,Z):=assert(x=y,z);}>> > Begin

[fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
Hi, See: http://forum.lazarus.freepascal.org/index.php/topic,40223.msg277657/ This seems rather unexpected. Is it a bug? program v; {$ifdef windows} {$apptype console} {$endif} uses variants; var X: Variant; B: Boolean; begin X := -1.5; writeln('X = ',X); B := VarIsFloat(X);

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Mark Morgan Lloyd
On 25/02/18 10:30, Florian Klämpfl wrote: Am 25.02.2018 um 11:12 schrieb Mark Morgan Lloyd:> On 25/02/18 02:15, Ozz Nixon wrote:>> {$MACRO ON}>> {$DEFINE _CTASSERT(X,Y,Z):=assert(x=y,z);}>> Begin   _CTASSERT(1,1,'Constant failed.');end.> > I don't believe parameters are supported :-(> Why so

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Michael Van Canneyt
On Sun, 25 Feb 2018, Bart wrote: Hi, See: http://forum.lazarus.freepascal.org/index.php/topic,40223.msg277657/ This seems rather unexpected. Not really. The abs() function is overloaded for different types. The compiler does not know at compile time what type the variant is, how can

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Florian Klämpfl
Am 25.02.2018 um 13:28 schrieb Giuliano Colla: > Il 25/02/2018 13:15, Sven Barth via fpc-devel ha scritto: > >> Yes, we definitely feel good about this, because we don't *want* parameter >> support in FPC's macro >> handling. > > Maybe I'm obtuse, but I fail to grasp the reason why. > Can you

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Giuliano Colla
Il 25/02/2018 13:15, Sven Barth via fpc-devel ha scritto: Yes, we definitely feel good about this, because we don't *want* parameter support in FPC's macro handling. Maybe I'm obtuse, but I fail to grasp the reason why. Can you elaborate a bit more? Thanks Giuliano

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Sven Barth via fpc-devel
Am 25.02.2018 03:01 schrieb "Ozz Nixon" : {$MACRO ON} {$DEFINE _CTASSERT(X,Y,Z):=assert(x=y,z);} Begin _CTASSERT(1,1,'Constant failed.'); end. Macros with arguments are not supported. Regards, Sven ___ fpc-devel maillist -

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Mark Morgan Lloyd
On 25/02/18 02:15, Ozz Nixon wrote: {$MACRO ON} {$DEFINE _CTASSERT(X,Y,Z):=assert(x=y,z);} Begin _CTASSERT(1,1,'Constant failed.');end. I don't believe parameters are supported :-( -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Florian Klämpfl
Am 25.02.2018 um 11:12 schrieb Mark Morgan Lloyd: > On 25/02/18 02:15, Ozz Nixon wrote: >> {$MACRO ON} >> {$DEFINE _CTASSERT(X,Y,Z):=assert(x=y,z);} >> Begin   _CTASSERT(1,1,'Constant failed.');end. > > I don't believe parameters are supported :-( > Why so sad? They are not supported on purpose

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Michael Van Canneyt
On Sun, 25 Feb 2018, Bart wrote: On Sun, Feb 25, 2018 at 5:01 PM, Jonas Maebe wrote: As Michael said, overloads are selected at compile time. This is true for both FPC and Delphi. We even have over a 100 unit tests that we ran under Delphi to reverse engineer their

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 5:34 PM, Michael Van Canneyt wrote: >> So, would it be possible to have an overloaded Abs(V: Variant): >> Variant; function in the variants unit? > > > I advise against it. > > S : String; > > begin > S:='My very nice string'; > S:=Abs(S); >

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Jonas Maebe
On 25/02/18 16:41, Bart wrote: Delphi 10.2 Tokyo: X = -1,5 VarIsFloat : TRUE VarIsNumeric: TRUE VarIsOrdinal: FALSE After Abs() X = 1,5 VarIsFloat : TRUE VarIsNumeric: TRUE VarIsOrdinal: FALSE I asked to test with "X := -1" to see if Delphi always chooses the float overload. As Michael said,

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Florian Klämpfl
Am 25.02.2018 um 18:21 schrieb Giuliano Colla: > Il 25/02/2018 13:55, Florian Klämpfl ha scritto: > >>> To limit their use. > > Well, just for sake of argument, it appears to me a rather drastic approach. > > You may write other similar pages on stackoverflow, telling why Dereferencing > is

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Jonas Maebe
On 25/02/18 15:59, Bart wrote: I don't know how Delphi behaves, but the official Delphi docs state that Abs() only has overloads for floats, integer and int64. If their compiler behaves as the docs say, Abs(Variant) would be a syntax error. No, because variant can be implicitly converted to

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
Delphi 10.2 Tokyo: X = -1,5 VarIsFloat : TRUE VarIsNumeric: TRUE VarIsOrdinal: FALSE After Abs() X = 1,5 VarIsFloat : TRUE VarIsNumeric: TRUE VarIsOrdinal: FALSE I asked to test with "X := -1" to see if Delphi always chooses the float overload. Bart

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 5:01 PM, Jonas Maebe wrote: > As Michael said, overloads are selected at compile time. This is true for > both FPC and Delphi. We even have over a 100 unit tests that we ran under > Delphi to reverse engineer their selection priorities in case of

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 3:40 PM, Michael Van Canneyt wrote: > Only if we add an > Abs(Variant) : Variant; which will then make the choice will this work. If the compiler accepts Abs(Variant), it should IMHO have a correct overload for this. (Maybe in the variants

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Ozz Nixon
Thank you Sven! I saw all of the threads on this topic in 2011, but, figured I would ask here if it had changed, and I was just doing it wrong. We are in the process of porting Minix 3 source to Free Pascal (Andrew T. tells me it can’t be done, and I know FPC can handle it). I just wanted to

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 1:01 PM, Michael Van Canneyt wrote: > The compiler does not know at compile time what type the variant is, how can > you expect it to choose the "right" overloaded version ? I would have expected that it will choose the right one @runtime . Bart

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Bart
On Sun, Feb 25, 2018 at 5:59 PM, Michael Van Canneyt wrote: >> So, all we can do is let the compiler pick the float version for >> Abs(Variant)? > > > It seems so. OK, for D compatibilty (untill they change that). > Better yet, don't use variants. They violate what

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Giuliano Colla
Il 25/02/2018 18:34, Florian Klämpfl ha scritto: http://www.gnu-pascal.de/gpc/Preprocessor.html, nobody prevents people to run a preprocessor before FPC gets the code. That's a constructive suggestion. If fpc doesn't implement an actual preprocessor, but macro expansion is part of the

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Michael Van Canneyt
On Sun, 25 Feb 2018, Bart wrote: On Sun, Feb 25, 2018 at 1:01 PM, Michael Van Canneyt wrote: The compiler does not know at compile time what type the variant is, how can you expect it to choose the "right" overloaded version ? I would have expected that it will

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Michael Van Canneyt
On Sun, 25 Feb 2018, Bart wrote: On Sun, Feb 25, 2018 at 5:34 PM, Michael Van Canneyt wrote: So, would it be possible to have an overloaded Abs(V: Variant): Variant; function in the variants unit? I advise against it. S : String; begin S:='My very nice

Re: [fpc-devel] MACRO - correct syntax?

2018-02-25 Thread Giuliano Colla
Il 25/02/2018 13:55, Florian Klämpfl ha scritto: To limit their use. Well, just for sake of argument, it appears to me a rather drastic approach. You may write other similar pages on stackoverflow, telling why Dereferencing is evil, Typecasting is evil, or why "Absolute" or the "with"

Re: [fpc-devel] Abs(Variant) unexpected result

2018-02-25 Thread Rik van Kekem
On 25/02/18 17:59, Michael Van Canneyt wrote: On Sun, 25 Feb 2018, Bart wrote: On Sun, Feb 25, 2018 at 5:34 PM, Michael Van Canneyt wrote: So, all we can do is let the compiler pick the float version for Abs(Variant)? It seems so. Better yet, don't use variants. They