Liste des Groupes | Revenir à cu shell |
On 03/04/2024 19:19, Keith Thompson wrote:David Brown <david.brown@hesbynett.no> writes:>On 03/04/2024 18:00, Keith Thompson wrote:[...]David Brown <david.brown@hesbynett.no> writes:Yes, but it's not the same thing. Perl has postfix conditionals, so>That's probably the reason almost no one uses it. That post is theNo, Perl's conditional expressions use the same syntax as C's.
first time I have ever seen conditional expressions outside of a brief
mention in a tutorial on Python conditionals showing how to write
normal conditionals in the language. I think Python stole this one
from Perl.
I am not very familiar with Perl, and don't know what are expressions
or statements. Perhaps I have been imagining things. I had the idea
that in Perl you could write "<do_this> if <condition>" as an
alternative to the more common imperative language ordering "if
<condition> then <do_this>".
you
can write:
statement if condition;
but that's a statement, not an expression, and there's no form
equivalent to if/else. It's a specific case of "statement modifiers",
where the keyword can be any of if, unless, while, until, for, foreach,
or when. (The latter is for an experimental "switch" feature, disabled
by default in recent releases.)
OK. That's a lot more than I knew.
>
However, I don't see a relevant distinction between a statement and an
expression as particularly significant here, at least in terms of code
clarity.
Les messages affichés proviennent d'usenet.