Questions tagged [conditional]
For questions about conditionals, language constructs that enable the execution of specific code based on certain conditions.
8 questions
6
votes
5
answers
3k
views
What are the consequences of allowing breaking/returning from every statement?
One beneficial feature of Rust is that loop, the unconditional looping statement, allows so-called "returning break", ...
0
votes
1
answer
430
views
Why don't assemblers, even those that support arithmetic expressions in compile-time constants, tend to support the ternary conditional `?:` operator?
So, as per my previous question, I added the support for the ternary conditional operator ?: into my PicoBlaze assembler written in JavaScript for compile-time ...
1
vote
0
answers
244
views
Designing conditional compilation blocks
ECMAScript and C have a totally different nature. Certain syntactic features are cryptic in C and don't fit exactly into ECMAScript dialects.
For example, I don't think the following:
...
20
votes
10
answers
4k
views
Are there any languages where conditions are not first-class expressions?
Novices writing in mainstream languages often don't realise that conditions like x < y are expressions which can occur anywhere an expression is syntactically ...
12
votes
7
answers
2k
views
A conditional block with unconditional intermediate code
One problem that is hard to make not at least somewhat repetitive is if there is code that needs to be executed in a certain order, and the intermediate code is unconditional but first and last code ...
4
votes
9
answers
3k
views
What are pros/cons of ternary conditional operators?
There are some languages that support ternary operator. There are Python, C, JavaScript, PHP.
In languages like C and JavaScript, the syntax is like this:
...
12
votes
2
answers
736
views
What are some caveats to be careful about when implementing the `?:` (ternary conditional) operator?
Thus far, I see two things that can go wrong when implementing the ?: (ternary conditional) operator:
PHP famously incorrectly implemented the ...
18
votes
15
answers
2k
views
What are the syntax options for implementing a ternary "if" operator?
The ternary "if" operator is a syntactic construct for returning one of two values based upon a boolean condition. In most C-family languages its syntax resembles ...