Talk:Inverted syntax: Difference between revisions

From Rosetta Code
Content added Content deleted
(reply to questions asked)
(→‎perl vs. perl6: new section)
Line 23: Line 23:


Mark.
Mark.

== perl vs. perl6 ==

Currently, the perl entry says:

:In perl, inverted syntax can also be used with the ternary operator:

:<lang perl>$a = $ok ? $b : $c; # Traditional syntax
($ok ? $b : $c) = $a; # Inverted syntax
</lang>

But:

<lang>$ perl -le '$ok= 1; $b= 2; $c= 3; ($a ? $b : $c) = $a; print $a'

$ perl -le '$ok= 1; $b= 2; $c= 3; $a = $ok ? $b : $c; print $a'
2

$ perl -le '(1 ? 2 : 3) = $a; print $a'
Can't modify constant item in list assignment at -e line 1, near "$a;"
Execution of -e aborted due to compilation errors.

$ perl --version

This is perl, v5.10.1 ...</lang>

So, in some versions of perl the two statements are both legal, but not equivalent.

I imagine that the inverted syntax shown here could work in some version of perl6. But I do not yet have any working implementation of perl6 yet, so I do not know if there are additional issues -- Raduko? Pugs? Not yet implemented?. Anyways, I think this one could use some clarity. --[[User:Rdm|Rdm]] 14:21, 6 June 2011 (UTC)

Revision as of 14:21, 6 June 2011

More meaningful name?

The current "Inverted syntax" doesn't mean much on its own. I don't have much of an alternative, but how about "Syntax/Trailing conditionals". --Paddy3118 05:10, 1 June 2011 (UTC)

Or "Syntax/Statement modifiers" --Paddy3118 05:49, 1 June 2011 (UTC)

There is such a term as "inverted syntax", although in relation to programming, there are only a few people that use that term. I say the phrase is valid, of course,

Google for +"inverted syntax" +programming

Markhobley 14:35, 1 June 2011 (UTC)

It's not really question of validity. It's a question of popularity. For instance, we chose "Greatest common divisor" over "Greatest common factor" partly because gcd was created first here, but also because greatest common divisor feels like it's a little more common. In any case, this is what we have redirect pages for. Try to think of what "people" call it (or would call it), and set up redirects for other names. --Mwn3d 14:49, 1 June 2011 (UTC)
I do not find the google results very convincing. Most of the ones I looked at were synthetic text and the one that I found that did not relate to perl/python if statements used it apologetically, for an issue related to grammatical awkwardness in english. That said, I do not think we need any sort of "absolute correctness", and I have no personal objection to this task being called whatever people think is right. And if perl jargon is the way to go, so be it. --Rdm 14:56, 1 June 2011 (UTC)
"Postfix flow control"? Or "postfix control structures", or whatever. Here's one relevant usage: http://search.cpan.org/~elliotjs/Perl-Critic-1.116/lib/Perl/Critic/Policy/ControlStructures/ProhibitPostfixControls.pm .
--DanBron 18:58, 1 June 2011 (UTC)


We have suggestions. maybe people could argue for/against until we come to some conclusion? (P.S. what does the original task creator think)? --Paddy3118 20:53, 1 June 2011 (UTC)

I think "Inverted Syntax" is the appropriate name and I use it in documentation that I produce here (which includes a terminology dictionary). However my inverted syntax definition, together with more than half of my dictionary is incomplete at this time.

FWIW I also link the alias "Reverse Polish Syntax" to the "Inverted Syntax" placeholder on my website (offline at the moment), but I am a strange person.

Mark.

perl vs. perl6

Currently, the perl entry says:

In perl, inverted syntax can also be used with the ternary operator:
<lang perl>$a = $ok ? $b : $c; # Traditional syntax

($ok ? $b : $c) = $a; # Inverted syntax </lang>

But:

<lang>$ perl -le '$ok= 1; $b= 2; $c= 3; ($a ? $b : $c) = $a; print $a'

$ perl -le '$ok= 1; $b= 2; $c= 3; $a = $ok ? $b : $c; print $a' 2

$ perl -le '(1 ? 2 : 3) = $a; print $a' Can't modify constant item in list assignment at -e line 1, near "$a;" Execution of -e aborted due to compilation errors.

$ perl --version

This is perl, v5.10.1 ...</lang>

So, in some versions of perl the two statements are both legal, but not equivalent.

I imagine that the inverted syntax shown here could work in some version of perl6. But I do not yet have any working implementation of perl6 yet, so I do not know if there are additional issues -- Raduko? Pugs? Not yet implemented?. Anyways, I think this one could use some clarity. --Rdm 14:21, 6 June 2011 (UTC)