Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Schnell
On 02/02/2016 10:31 AM, Graeme Geldenhuys wrote: Exactly! I'm glad somebody noticed that too. Of course I did notice :-) . V := If a < 3 then 1 else 2; In fact extends a several language paradigms: - a keyword (such as "if") returns a value - a statement (such as "if ", and the conte

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread John Lee
on, and on and on blah blah - lets move on! On 2 February 2016 at 17:06, Martin wrote: > On 02/02/2016 16:49, Sven Barth wrote: > >> >> >> > also if we are discussing (are we?) a form like >> > x:= iIf a>b iThen c iElse b; >> > then why not >> > x:= a>b ifThen c ifElse b; >> >> Because I

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin
On 02/02/2016 16:49, Sven Barth wrote: > also if we are discussing (are we?) a form like > x:= iIf a>b iThen c iElse b; > then why not > x:= a>b ifThen c ifElse b; Because I won't add new keywords just for this feature, especially if they are inside normal code (I'm a bit less strict o

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Lukasz Sokol
On 02/02/16 16:28, Lukasz Sokol wrote: > (bikeshedding mode=on) > > On 02/02/16 11:24, Marcos Douglas wrote: >> On Tue, Feb 2, 2016 at 7:49 AM, Michael Van Canneyt >> wrote: >>> It is not a statement, it is an expression. >>> >>> I prefer >>> x := iif Obj = nil then 0 else Obj.Value; >>> over >

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 15:39 schrieb "Serguei TARASSOV" : > > On 02/02/2016 15:16, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> Date: Tue, 2 Feb 2016 14:36:25 +0100 >> From: Sven Barth >> >> >>> > >>> >You confuse left-to-right operator's precedence with function arguments evaluation >>> . >> >> No,

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Lukasz Sokol
(bikeshedding mode=on) On 02/02/16 11:24, Marcos Douglas wrote: > On Tue, Feb 2, 2016 at 7:49 AM, Michael Van Canneyt > wrote: >> It is not a statement, it is an expression. >> >> I prefer >> x := iif Obj = nil then 0 else Obj.Value; >> over >> x := if Obj = nil then 0 else Obj.Value; >> >> B

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marcos Douglas
On Tue, Feb 2, 2016 at 4:10 PM, Martin wrote: > Also there are many who want assignments > X := inline y := 1; > Now that might be looking nice if all you do is set 10 variables to 1. > But > x := inline if inline y := foo() > inline z := bar() then inline m:= 1 else > inline m:=2; > *OUCH*!! As

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin
On 02/02/2016 17:35, Marcos Douglas wrote: On Tue, Feb 2, 2016 at 3:06 PM, Martin wrote: In this case, I dislike the x := if a then b else c; Why not as below, using 'inline' keyword? x := inline if a then b else c; because it still resembles a statement. (even so, I guess technical

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Jürgen Hestermann
Am 2016-02-02 um 18:39 schrieb Maciej Izak: Is possible to close thread on mailing list? -,- Simply do not open (and delete) mails with "IfThen" in subject. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Maciej Izak
Is possible to close thread on mailing list? -,- -- Best regards, Maciej Izak ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marcos Douglas
On Tue, Feb 2, 2016 at 3:06 PM, Martin wrote: > In this case, I dislike the >x := if a then b else c; Why not as below, using 'inline' keyword? x := inline if a then b else c; It is simple and elegant; Is different than a simple 'if'; Could be used to extend 'case' too; Don't looks like

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Martin wrote: On 02/02/2016 16:49, Sven Barth wrote: > also if we are discussing (are we?) a form like > x:= iIf a>b iThen c iElse b; > then why not > x:= a>b ifThen c ifElse b; Because I won't add new keywords just for this feature, especially if they are insid

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 16:11 schrieb "Martin" : > > On 02/02/2016 13:24, Sven Barth wrote: >> >> >> > Look at the "iif" as an statement and the things will be simple. >> >> BECAUSE. IT. IS. *NOT*. A. STATEMENT! >> It never was and it never will be! It returns a value and thus by definition it is an expressi

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Jürgen Hestermann
Am 2016-02-02 um 11:41 schrieb Mark Morgan Lloyd: > Michael Van Canneyt wrote: > Yes, and that's why to get the desired semantics it's more appropriate to use if then else rather than iif() etc. > Please correct me if I'm wrong, but my understanding is that in all cases where parameters are

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Andreas Berger
On Tue 02/02/2016 10:52, Serguei TARASSOV wrote: On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 02 Feb 2016 10:32:28 -0200 From: Andreas Berger On Tue 02/02/2016 09:27, Jonas Maebe wrote: > >The parameter evaluation order issue is irrelevant in this context: >D

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Martin Schreiber wrote: On Tuesday 02 February 2016 13:39:17 Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Martin Schreiber wrote: On Tuesday 02 February 2016 13:22:01 Jonas Maebe wrote: It just needs to be documented properly. It is a non-issue for me. It is a deal b

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin
On 02/02/2016 13:24, Sven Barth wrote: > Look at the "iif" as an statement and the things will be simple. BECAUSE. IT. IS. *NOT*. A. STATEMENT! It never was and it never will be! It returns a value and thus by definition it is an expression! +1 And imho that why it is important that it doe

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 02 Feb 2016 13:22:01 +0100 From: Jonas Maebe Michael Van Canneyt wrote on Tue, 02 Feb 2016: [evaluating all arguments to a function/intrinsic] >I'm just trying to to put any foaming-at-the-mouth argumentation >using

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 02 Feb 2016 10:32:28 -0200 From: Andreas Berger On Tue 02/02/2016 09:27, Jonas Maebe wrote: > >The parameter evaluation order issue is irrelevant in this context: >Delphi guarantees left-to-right (or used to anyway,

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Henry Vermaak
On Tue, Feb 02, 2016 at 01:12:25PM +0100, Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Henry Vermaak wrote: > >So you are saying that relying on all function arguments being > >evaluated is bad? > > I am saying that the difference between this behaviour and the > behaviour where they may not a

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin Schreiber
On Tuesday 02 February 2016 13:22:01 Jonas Maebe wrote: > Michael Van Canneyt wrote on Tue, 02 Feb 2016: > > [evaluating all arguments to a function/intrinsic] > > > I'm just trying to to put any foaming-at-the-mouth argumentation > > using this particular argument in perspective. > > I think this

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Martin Schreiber wrote: On Tuesday 02 February 2016 13:22:01 Jonas Maebe wrote: It just needs to be documented properly. It is a non-issue for me. It is a deal breaker for me. Agreed. Quick ! We should call the New York Times or Frankfurter Allgemeiner Zeitung, M

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Andreas Berger wrote: On Tue 02/02/2016 09:27, Jonas Maebe wrote: The parameter evaluation order issue is irrelevant in this context: Delphi guarantees left-to-right (or used to anyway, this may have changed), FPC doesn't guarantee anything. Wow, what's this? I never

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 15:16, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 2 Feb 2016 14:36:25 +0100 From: Sven Barth > >You confuse left-to-right operator's precedence with function arguments evaluation . No, he does not. Delphi and TP indeed guarantee an evaluation(!) from left to right

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Jonas Maebe wrote: Michael Van Canneyt wrote on Tue, 02 Feb 2016: [evaluating all arguments to a function/intrinsic] I'm just trying to to put any foaming-at-the-mouth argumentation using this particular argument in perspective. I think this is rather disingenuous afte

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Maciej Izak
2016-02-02 13:12 GMT+01:00 Michael Van Canneyt : > "iif(a,b,c) > is fundamentally different in behaviour from > functionxyy(a,b,c)" > > simply laughable in my eyes, because likely 99,99% of programmers won't > know the > difference. As Graeme said: 'I guess I was just lucky it never happened to >

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: > >> Including all other functions called iif(). > >> > >>> >It just needs to be > >>> >documented properly. It is a non-issue for me. > >> It is a deal breaker for me. > > Completely agreed with Jonas. > > I'm afraid to stay with FPC 2.6 for the

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Dmitry Boyarintsev
On Tue, Feb 2, 2016 at 7:45 AM, Henry Vermaak wrote: > Exceptions to standard behaviour is bad, just because there are > exceptions doesn't mean that we need to create more of them. > Documenting something doesn't make the behaviour intuitive. > > Too many exceptions create a rule? :) I'd suspec

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 13:56 schrieb "Serguei TARASSOV" : > > On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> Date: Tue, 02 Feb 2016 13:22:01 +0100 >> From: Jonas Maebe >> >> Michael Van Canneyt wrote on Tue, 02 Feb 2016: >> >> [evaluating all arguments to a function/intrinsic] >>

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Sven Barth wrote: Am 02.02.2016 13:38 schrieb "Andreas Berger" : On Tue 02/02/2016 09:27, Jonas Maebe wrote: The parameter evaluation order issue is irrelevant in this context: Delphi guarantees left-to-right (or used to anyway, this may have changed), FPC doesn't gu

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 13:51 schrieb "Serguei TARASSOV" : > > On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> Date: Tue, 02 Feb 2016 10:32:28 -0200 >> From: Andreas Berger >> >> >> On Tue 02/02/2016 09:27, Jonas Maebe wrote: >>> >>> > >>> >The parameter evaluation order issue is ir

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 13:38 schrieb "Andreas Berger" : > > > On Tue 02/02/2016 09:27, Jonas Maebe wrote: >> >> >> The parameter evaluation order issue is irrelevant in this context: Delphi guarantees left-to-right (or used to anyway, this may have changed), FPC doesn't guarantee anything. >> > Wow, what's

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread John Lee
Sigh, thought everyone (eventually) agreed that we'd change to algol/ada x:=if a>b then 1 else 2; so why are we going on & on & on about this? john On 2 February 2016 at 13:20, Sven Barth wrote: > Am 02.02.2016 11:42 schrieb "Mark Morgan Lloyd" < > markmll.fpc-pas...@telemetry.co.uk>: > > > > M

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 12:03 schrieb "Serguei TARASSOV" : > > On 02/02/2016 11:42, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> On Tue, 2 Feb 2016, Sven Barth wrote: >> >> >No, the second is always better because safer. >> > >> >x := iif (Obj = nil, 0, Obj.Value); >> >This will raise access violatio

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 11:42 schrieb "Mark Morgan Lloyd" < markmll.fpc-pas...@telemetry.co.uk>: > > Michael Van Canneyt wrote: > >> Call me old fashioned, but then I think >> foo:=iif(Condition1, >>iif(Condition2, ThenExpr1, ElseExpr1), >>iif(Condition3, ThenExpr2, ElseExpr2)); >>

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Serguei TARASSOV wrote: On 02/02/2016 13:41, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 02 Feb 2016 13:22:01 +0100 From: Jonas Maebe Michael Van Canneyt wrote on Tue, 02 Feb 2016: [evaluating all arguments to a function/intrinsic] >I'm just trying to to p

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 01:12:25PM +0100, Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: So you are saying that relying on all function arguments being evaluated is bad? I'm just trying to to put any foaming-at-the-mouth argume

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin Schreiber
On Tuesday 02 February 2016 13:39:17 Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Martin Schreiber wrote: > > On Tuesday 02 February 2016 13:22:01 Jonas Maebe wrote: > >>> It just needs to be > >>> documented properly. It is a non-issue for me. > >> > >> It is a deal breaker for me. > > > > Agr

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Andreas Berger
On Tue 02/02/2016 09:27, Jonas Maebe wrote: The parameter evaluation order issue is irrelevant in this context: Delphi guarantees left-to-right (or used to anyway, this may have changed), FPC doesn't guarantee anything. Wow, what's this? I never knew this. I have been using Borland products

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Jonas Maebe
Michael Van Canneyt wrote on Tue, 02 Feb 2016: [evaluating all arguments to a function/intrinsic] I'm just trying to to put any foaming-at-the-mouth argumentation using this particular argument in perspective. I think this is rather disingenuous after your own foaming-at-the-mouth hyperbol

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Henry Vermaak wrote: You only talked about the order of evaluation in that mail, while Henry is talking about whether the arguments are evaluated at all. I am aware of that (I knew I should have mentioned it explicitly, this is a programmers list!), but the exact same ob

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread silvioprog
On Tue, Feb 2, 2016 at 6:49 AM, Michael Van Canneyt wrote: [...] > No, the second is always better because safer. >> >> x := iif (Obj = nil, 0, Obj.Value); >> This will raise access violation as a normal function or you depend on >> compiler implementation for this special case. And you should re

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marcos Douglas
On Tue, Feb 2, 2016 at 8:32 AM, Sven Barth wrote: > It's not a statement, it's an expression. Also I won't introduce a new > keyword ("iif") just for this. Thank you for this. Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org h

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread silvioprog
On Tue, Feb 2, 2016 at 6:07 AM, Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Maciej Izak wrote: > >> we can even mix to gain more clear code: >> >> foo := >> if Condition1 then >>iif(Condition2, ThenExpr1, ElseExpr1) >> else >>iif(Condition3, ThenExpr2, ElseExpr2); >> >> much more r

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Mark Morgan Lloyd wrote: The "if then" construct is really confusing. "if then" is a statement, not an expression. Yes, and that's why to get the desired semantics it's more appropriate to use if then else rather than iif() etc. Please cor

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Henry Vermaak
On Tue, Feb 02, 2016 at 12:34:17PM +0100, Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Jonas Maebe wrote: > >Michael Van Canneyt wrote on Tue, 02 Feb 2016: > >>On Tue, 2 Feb 2016, Henry Vermaak wrote: > >>>On Tue, Feb 02, 2016 at 11:24:57AM +0100, Michael Van Canneyt > >>>wrote: > On Tue, 2

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 12:03:14PM +0100, Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: When you call a function all the arguments get evaluated before the function gets called. iif will look exactly like a function call, but al

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Jonas Maebe wrote: Michael Van Canneyt wrote on Tue, 02 Feb 2016: On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 11:24:57AM +0100, Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: Pascal is not a language full of programmer traps

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Henry Vermaak
On Tue, Feb 02, 2016 at 12:03:14PM +0100, Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Henry Vermaak wrote: > >When you call a function all the arguments get evaluated before the > >function gets called. iif will look exactly like a function call, > >but all the arguments may not be evaluated

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Jonas Maebe
Michael Van Canneyt wrote on Tue, 02 Feb 2016: On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 11:24:57AM +0100, Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: Pascal is not a language full of programmer traps, let's try not to add any! Well, see my

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marcos Douglas
On Tue, Feb 2, 2016 at 7:49 AM, Michael Van Canneyt wrote: > It is not a statement, it is an expression. > > I prefer > x := iif Obj = nil then 0 else Obj.Value; > over > x := if Obj = nil then 0 else Obj.Value; > > Because it clearly differentiates between if (a statement) and iif (an > expre

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: On Tue, 2 Feb 2016, Michael Van Canneyt wrote: At least Firebird & Microsoft SQL Server and MS-Access contain it. FastReport uses it. I use this since 15+ years, I didn't make up this name myself:-) These products (remember Ex

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 11:42, fpc-pascal-requ...@lists.freepascal.org wrote: On Tue, 2 Feb 2016, Sven Barth wrote: >No, the second is always better because safer. > >x := iif (Obj = nil, 0, Obj.Value); >This will raise access violation as a normal function or you depend on compiler implementation for thi

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 11:24:57AM +0100, Michael Van Canneyt wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 10:49:03AM +0100, Michael Van Canneyt wrote: So the iif in either functional or expression form has my vote. I'm

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Mark Morgan Lloyd wrote: Michael Van Canneyt wrote: Call me old fashioned, but then I think foo:=iif(Condition1, iif(Condition2, ThenExpr1, ElseExpr1), iif(Condition3, ThenExpr2, ElseExpr2)); is more clear. The "if then" construct is really confus

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Henry Vermaak
On Tue, Feb 02, 2016 at 11:24:57AM +0100, Michael Van Canneyt wrote: > On Tue, 2 Feb 2016, Henry Vermaak wrote: > > >On Tue, Feb 02, 2016 at 10:49:03AM +0100, Michael Van Canneyt wrote: > >>So the iif in either functional or expression form has my vote. > > > >I'm surprised that you support iif in

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Sven Barth wrote: Am 02.02.2016 10:20 schrieb "Felipe Monteiro de Carvalho" < felipemonteiro.carva...@gmail.com>: If other people already use "iif" then maybe it is better to use the same name? Also I vaguely remember at least a few functions in existing code named IfT

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: Call me old fashioned, but then I think foo:=iif(Condition1, iif(Condition2, ThenExpr1, ElseExpr1), iif(Condition3, ThenExpr2, ElseExpr2)); is more clear. The "if then" construct is really confusing. "if then" is a statement, not an expression.

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 11:30, fpc-pascal-requ...@lists.freepascal.org wrote: On Tue, 2 Feb 2016, Henry Vermaak wrote: >On Tue, Feb 02, 2016 at 10:49:03AM +0100, Michael Van Canneyt wrote: >>So the iif in either functional or expression form has my vote. > >I'm surprised that you support iif in functio

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 11:27 schrieb "Michael Van Canneyt" : > > > > On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > >> On 02/02/2016 10:54, fpc-pascal-requ...@lists.freepascal.org wrote: >> >>> On Tue, 2 Feb 2016, Michael Van Canneyt wrote On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > No, the

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 10:20 schrieb "Felipe Monteiro de Carvalho" < felipemonteiro.carva...@gmail.com>: > > If other people already use "iif" then maybe it is better to use the same name? > > Also I vaguely remember at least a few functions in existing code > named IfThen which would conflict with the new

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 11:12 schrieb "Serguei TARASSOV" : > > On 02/02/2016 10:54, fpc-pascal-requ...@lists.freepascal.org wrote: > >> On Tue, 2 Feb 2016, Michael Van Canneyt wrote >>> >>> >>> On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > No, the second is always better because safer. >>> >>> > >>> >x := ii

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Mark Morgan Lloyd
Martin Schreiber wrote: And it could be extended to " V:= case i1 of 1: 'one'; 2: 'two'; else 'none'; end; I'm rather less happy with this because of the difficulty of inserting inline assertions etc. to catch unexpected values. -- Mark Morgan Lloyd markMLl .AT. telemetry

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 10:41 schrieb "Serguei TARASSOV" : > > On 02/02/2016 10:29, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> 2016-02-01 10:59 GMT+01:00 Michael Schnell: >> Same here. I see no reason to differ from it. Introducing new >> incompatibility is bad idea. For me is good to have booth (O

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 10:38 schrieb "Marco van de Voort" : > > - I like &if ;) > > I don't see the point. And if a funky character is needed then use another > one, don't add a third overload to &. (statement to intrinsic instead of > statement to identifier and octal) He meant to use "if" as the name for

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Serguei TARASSOV wrote: On 02/02/2016 10:54, fpc-pascal-requ...@lists.freepascal.org wrote: On Tue, 2 Feb 2016, Michael Van Canneyt wrote On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > No, the second is always better because safer. > >x := iif (Obj = nil, 0, Obj.Value)

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Henry Vermaak wrote: On Tue, Feb 02, 2016 at 10:49:03AM +0100, Michael Van Canneyt wrote: So the iif in either functional or expression form has my vote. I'm surprised that you support iif in function call form. Making something that looks like a function call but may n

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Sven Barth
Am 02.02.2016 08:34 schrieb "Anthony Walter" : > > Sven, > > I missed this post when you made it a two days ago. If someone hasn't already asked, does your implementation support short circuit evaluation? > > For example: > > BasketCount := IfThen(ShoppingList <> nil, ShoppingList.Count, 0); > > Wh

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Henry Vermaak
On Tue, Feb 02, 2016 at 10:49:03AM +0100, Michael Van Canneyt wrote: > So the iif in either functional or expression form has my vote. I'm surprised that you support iif in function call form. Making something that looks like a function call but may not behave as a function call (short cut eval)

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 10:54, fpc-pascal-requ...@lists.freepascal.org wrote: On Tue, 2 Feb 2016, Michael Van Canneyt wrote On Tue, 2 Feb 2016, Serguei TARASSOV wrote: > No, the second is always better because safer. > >x := iif (Obj = nil, 0, Obj.Value); >This will raise access violation as a normal f

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Graeme Geldenhuys wrote: On 2016-02-02 09:44, Michael Van Canneyt wrote: N:=iif(Assigned(A),A.Name,'Nil'); You'll get a crash using regular functions because All arguments are evaluated prior to calling iif(). Okay, fair enough. Thanks for the example. Then again, i

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Martin Schreiber
On Tuesday 02 February 2016 10:41:39 Serguei TARASSOV wrote: > On 02/02/2016 10:29, fpc-pascal-requ...@lists.freepascal.org wrote: > > 2016-02-01 10:59 GMT+01:00 Michael Schnell: > > Same here. I see no reason to differ from it. Introducing new > > incompatibility is bad idea. For me is good to hav

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Maciej Izak wrote: 2016-02-02 10:38 GMT+01:00 Marco van de Voort : I don't see the point. And if a funky character is needed then use another one, don't add a third overload to &. (statement to intrinsic instead of statement to identifier and octal) ";)" emoticon means

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Maciej Izak
2016-02-02 10:38 GMT+01:00 Marco van de Voort : > > - a little different behavior than in other languages (but still > compatible > > with Oxygene) > > How is it different behaviour from C then? The only practical application > that I see is in from C conversions (like ++ and --), so that you don'

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Graeme Geldenhuys
On 2016-02-02 09:44, Michael Van Canneyt wrote: > > N:=iif(Assigned(A),A.Name,'Nil'); > > You'll get a crash using regular functions because All arguments are > evaluated prior to calling iif(). Okay, fair enough. Thanks for the example. Then again, it is a relatively small corner case. I've

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Serguei TARASSOV wrote: On 02/02/2016 10:29, fpc-pascal-requ...@lists.freepascal.org wrote: 2016-02-01 10:59 GMT+01:00 Michael Schnell: Same here. I see no reason to differ from it. Introducing new incompatibility is bad idea. For me is good to have booth (Oxygene compatib

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Maciej Izak wrote: 2016-02-02 10:07 GMT+01:00 Michael Van Canneyt : Call me old fashioned, but then I think foo:=iif(Condition1, iif(Condition2, ThenExpr1, ElseExpr1), iif(Condition3, ThenExpr2, ElseExpr2)); is more clear. The "if then" construct

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Graeme Geldenhuys wrote: On 2016-02-02 09:07, Michael Van Canneyt wrote: The "if then" construct is really confusing. "if then" is a statement, not an expression. Exactly! I'm glad somebody noticed that too. I'm fine with the iif() syntax. It is used in a few languages

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Serguei TARASSOV
On 02/02/2016 10:29, fpc-pascal-requ...@lists.freepascal.org wrote: 2016-02-01 10:59 GMT+01:00 Michael Schnell: Same here. I see no reason to differ from it. Introducing new incompatibility is bad idea. For me is good to have booth (Oxygene compatible): x := iif (a < 3, 1, 2); V := If a < 3 then

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Marco van de Voort
In our previous episode, Maciej Izak said: > *the best new name for "IfThen intrinsic" is iif* > > unless someone has a good opposite arguments? Pros for iif: > > - no conflicts with existing RTL code base (in this matter much much better > than IfThen) > - compatible with existing pascal solutio

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Maciej Izak
2016-02-02 8:22 GMT+01:00 Maciej Izak : > 2016-02-01 10:59 GMT+01:00 Michael Schnell : > >> On 02/01/2016 09:35 AM, David Butler wrote: >> >>> >>> >>> Maybe call it "inlineif" or "iif", e..g >>> >>> x := iif (a < 3, 1, 2) >>> >>> It's iif in Oxygen. So why not keep that name ? > > > Same here. I s

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Graeme Geldenhuys
On 2016-02-02 09:07, Michael Van Canneyt wrote: > The "if then" construct is really confusing. > "if then" is a statement, not an expression. Exactly! I'm glad somebody noticed that too. I'm fine with the iif() syntax. It is used in a few languages for many years, so is a common and known name.

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Maciej Izak
2016-02-02 10:07 GMT+01:00 Michael Van Canneyt : > Call me old fashioned, but then I think > foo:=iif(Condition1, >iif(Condition2, ThenExpr1, ElseExpr1), >iif(Condition3, ThenExpr2, ElseExpr2)); > is more clear. > > The "if then" construct is really confusing. > "if then"

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Felipe Monteiro de Carvalho
If other people already use "iif" then maybe it is better to use the same name? Also I vaguely remember at least a few functions in existing code named IfThen which would conflict with the new one. But "iif", well I never saw anyone name a function like that... -- Felipe Monteiro de Carvalho __

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Michael Van Canneyt
On Tue, 2 Feb 2016, Maciej Izak wrote: we can even mix to gain more clear code: foo := if Condition1 then iif(Condition2, ThenExpr1, ElseExpr1) else iif(Condition3, ThenExpr2, ElseExpr2); much more readable than: Call me old fashioned, but then I think foo:=iif(Condition1,

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Mark Morgan Lloyd
LacaK wrote: Switch, Select, Which are all good except that they are very common English words. They might already be used by users in existing function names in their code. I prefer V := If Condition then ThenExpr else ElseExpr; +1 (for me is "if ... then ... else" also good understandable

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Anthony Walter
Sven, I missed this post when you made it a two days ago. If someone hasn't already asked, does your implementation support short circuit evaluation? For example: BasketCount := IfThen(ShoppingList <> nil, ShoppingList.Count, 0); Where evaluating ShoppingList.Count will cause an exception if Sh

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Maciej Izak
2016-02-01 10:59 GMT+01:00 Michael Schnell : > On 02/01/2016 09:35 AM, David Butler wrote: > >> >> >> Maybe call it "inlineif" or "iif", e..g >> >> x := iif (a < 3, 1, 2) >> >> It's iif in Oxygen. So why not keep that name ? Same here. I see no reason to differ from it. Introducing new incompati

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread LacaK
Switch, Select, Which are all good except that they are very common English words. They might already be used by users in existing function names in their code. I prefer V := If Condition then ThenExpr else ElseExpr; +1 (for me is "if ... then ... else" also good understandable and looks ni

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Michael Schnell
On 02/01/2016 09:35 AM, David Butler wrote: Maybe call it "inlineif" or "iif", e..g x := iif (a < 3, 1, 2) It's iif in Oxygen. So why not keep that name ? -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Marc Weustink
Sven Barth wrote: Am 01.02.2016 09:26 schrieb "Maciej Izak" mailto:hnb.c...@gmail.com>>: > > 2016-02-01 8:59 GMT+01:00 Marco van de Voort mailto:mar...@stack.nl>>: >> >> The only really bad thing is the name, as Florian already said, with the >> versions in strutils and math. The clash with

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Dennis Poon
Jürgen Hestermann wrote: Am 2016-02-01 um 19:45 schrieb Dmitry Boyarintsev: No matter what the language is, developers still want to write C... for the shortness of script Such people should simply use C. Pascal <> C and I am glad that this is true. In my humble opinion, the importance of

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Jürgen Hestermann
Am 2016-02-01 um 19:45 schrieb Dmitry Boyarintsev: No matter what the language is, developers still want to write C... for the shortness of script Such people should simply use C. Pascal <> C and I am glad that this is true. ___ fpc-pascal maillist

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Dennis
Roberto P. wrote: Maybe we shouldn't focus all that much on the " if " word..since all in all, it is meant to be differently from the language if-then-else What about using another word suggesting a choice? j := Switch(i < 32, 48, 21); j := Select(i < 32, 48, 21); j := Which(i < 32,

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Roberto P.
ists.freepascal.org < > fpc-pascal-boun...@lists.freepascal.org> em nome de Marco van de Voort < > mar...@stack.nl> > Enviado: segunda-feira, 1 de fevereiro de 2016 16:22 > Para: FPC-Pascal users discussions > Assunto: Re: [fpc-pascal] New feature: IfThen() intrinsic > >

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Philippe Lévi
cal.org em nome de Roberto P. Enviado: segunda-feira, 1 de fevereiro de 2016 19:34 Para: FPC-Pascal users discussions Assunto: Re: [fpc-pascal] New feature: IfThen() intrinsic Maybe we shouldn't focus all that much on the " if " word..since all in all, it is meant to be differen

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Philippe Lévi
iif ... sounds good to me! +1 ! Philippe De: fpc-pascal-boun...@lists.freepascal.org em nome de Marco van de Voort Enviado: segunda-feira, 1 de fevereiro de 2016 16:22 Para: FPC-Pascal users discussions Assunto: Re: [fpc-pascal] New feature: IfThen

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread silvioprog
On Mon, Feb 1, 2016 at 5:10 PM, Sven Barth wrote: [...] > > > When you format this code (e.g using Ctrl+D) the result is a very ugly > > syntax: > > > > var > > S: string; > > B: Boolen = True; > > begin > > S := > > if B then > > 'A' > > else > > 'B'; > > end; > > > > An

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Martin
On 01/02/2016 19:33, Marcos Douglas wrote: V := inline If Condition then ThenExpr else ElseExpr; ignoring the "inline" There are 3 styles (ignoring the names of identifiers used), can think of 1) function x := IfThen(a,b,c); 2) statement with return value x := If a Then b else c; 3) t

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Sven Barth
On 01.02.2016 21:02, silvioprog wrote: > On Mon, Feb 1, 2016 at 4:47 PM, Sven Barth > wrote: > > On 01.02.2016 20:33, Marcos Douglas wrote: > > On Mon, Feb 1, 2016 at 5:06 PM, David Butler > wrote: > >> Speaking perso

  1   2   >