Talk:Inverted syntax: Difference between revisions

no edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 24:
Mark.
 
==This perlis vs. perl6a nontask==
 
Answer this: What is the input data? How is it to be transformed?
: It's about language syntax, and has nothing to do with input data. Also, are you the same rude person who was using 192.139.122.42 before, Kaz? --[[User:Ledrug|Ledrug]] 05:53, 20 September 2011 (UTC)
 
== perl confusion ==
 
Currently, the perl entry says:
Line 59 ⟶ 64:
 
:: To be clear, in the inverted syntax version, Perl is selecting which lvalue to assign to. This sort of thing is interpreted by some as proof that Perl is a language for people who value tricks over readability. –[[User:Dkf|Donal Fellows]] 14:47, 6 June 2011 (UTC)
 
::: More specifically, in one example Perl was being used to select one of two values to assign '''to''' the variable $a and in the other example, Perl was being used to select one of two variables ($b or $c) to be assigned '''from''' the variable $a. And these two examples were presented side by side without comment, as if they were equivalent. --[[User:Rdm|Rdm]] 18:27, 6 June 2011 (UTC)
 
::: Ok, now the perl entry says "However this may produce different results to the traditional syntax form", but I think that that is misleading. The differing results in this case have nothing to do with the inverted conditional syntax. The differing results are because the left and right values on either side of the assignment operator are swapped. Both the traditional and inverted syntaxes would achieve the same result if they were both on the same side of the <code>=</code>. --[[User:Rdm|Rdm]] 20:00, 6 June 2011 (UTC)
 
== The C example ==
 
The C example is not right. <code>do {stuff} while (...)</code> is quite different from <code>while (...) {stuff}</code>, and if you treat them as the same, it's going to have consequences. For example, in the provided code itself, if you run the compiled program as <code>echo -n "" | ./a.out</code>, or press ctrl-D at the prompt, the <code>do{}while()</code> will access invalid memory and/or give a wrong answer. Don't tell readers <code>do{}while</code> is the same as <code>while{}</code>. --[[User:Ledrug|Ledrug]] 00:40, 4 September 2012 (UTC)
 
:Well, it doesn't say that do-while is the same, it only says it's the closest C comes to inverted syntax. True, it might mislead people not familiar with the language. --[[User:Oenone|Oenone]] 06:33, 5 September 2012 (UTC)
 
:: I don't know, given that the provided example has just the right bug, I'm not sure the original author ''didn't'' consider them exactly the same. Anyway, since they are not the same thing, there's no point of mentioning them in this task "just because". If someone ''has'' to put something under the C heading, it's probably better to stress their difference rather than similarity, along the lines of:<lang c>#include "stdio.h"
 
int main(void)
{
int i;
 
// seemingly unreachable loop
i = 0;
while (i < 0) { i++; }
printf("while{}: i = %d\n", i);
 
puts("");
i = 0;
do { i++; } while (i < 0);
printf("do{}while: i = %d\n", i);
 
// if iterator is modified inside while()
puts("");
i = 3;
while (--i) { printf("while{}: i = %d\n", i); }
 
puts("");
i = 3;
do { printf("do{}while: i = %d\n", i); } while (--i);
 
return 0;
}</lang>
== needumbrella=raining ==
Why would I abuse IF statements as this task seems to require?--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 14:15, 23 February 2018 (UTC)
2,171

edits