Ternary conditinals bug, I guess...

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Ternary conditinals bug, I guess...

Post by jacky »

So you know how there are 3 "expressions" involved : condition, value-if-true, and value-if-false. Both "value-if-true" and "value-if-false" should not include any concatenation, nor "secondary" ternary conditionals.

But actually, it seems to work fine if the additional ternary conditionals is on value-if-false. Here:

Code: Select all

msg confirm("first confirm") ? "ok 1" : confirm("second confirm?") ? "ok 2" : confirm("third confirm?") ? "ok 3" : "and so on...";
Works just fine. Do we call that a feature, or do you want to "remove" it?

I'd vote to keep it, since it can actually be useful, but given how it can't work for value-if-true even with appropriate parenthesis (which would be the bug I'd say), that might not be be wise...
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Ternary conditinals bug, I guess...

Post by admin »

jacky wrote:So you know how there are 3 "expressions" involved : condition, value-if-true, and value-if-false. Both "value-if-true" and "value-if-false" should not include any concatenation, nor "secondary" ternary conditionals.

But actually, it seems to work fine if the additional ternary conditionals is on value-if-false. Here:

Code: Select all

msg confirm("first confirm") ? "ok 1" : confirm("second confirm?") ? "ok 2" : confirm("third confirm?") ? "ok 3" : "and so on...";
Works just fine. Do we call that a feature, or do you want to "remove" it?

I'd vote to keep it, since it can actually be useful, but given how it can't work for value-if-true even with appropriate parenthesis (which would be the bug I'd say), that might not be be wise...
Oh, the restriction "should not include any concatenation" is not valid anymore since I added parentheses support. Of course, even without parentheses there's always some default binding of expressions, and in your example it happens work in some cases.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Ternary conditinals bug, I guess...

Post by jacky »

admin wrote:Oh, the restriction "should not include any concatenation" is not valid anymore since I added parentheses support. Of course, even without parentheses there's always some default binding of expressions, and in your example it happens work in some cases.
Okay, so the way I hear you is : this works thanks to default/unwritten parentheses, and using the right parentheses, it should work all the time. How do you suggest I should do it then, to use another ternary conditionals on value-if-true ?

Code: Select all

  msg ( (1==1) ? ( (2==2) ? "yes" : "no" ) : "error" );
  //shows: 0
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Ternary conditinals bug, I guess...

Post by admin »

jacky wrote:
admin wrote:Oh, the restriction "should not include any concatenation" is not valid anymore since I added parentheses support. Of course, even without parentheses there's always some default binding of expressions, and in your example it happens work in some cases.
Okay, so the way I hear you is : this works thanks to default/unwritten parentheses, and using the right parentheses, it should work all the time. How do you suggest I should do it then, to use another ternary conditionals on value-if-true ?

Code: Select all

  msg ( (1==1) ? ( (2==2) ? "yes" : "no" ) : "error" );
  //shows: 0
Whoops, yes, a bug! Let's see if I can fix it...

Post Reply