Talk:Topic variable: Difference between revisions

→‎Better definition for "topic variable": Difference between e.g. Perl and Python
(→‎Better definition for "topic variable": Difference between e.g. Perl and Python)
 
Line 19:
:This question inspired the Pyuthon entry, and I see you have followed :-)
:I guess if someone thinks it's wrong, they'll flag it. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 14:20, 11 April 2014 (UTC)
 
::I've read the [http://perldoc.perl.org/perlvar.html#General-Variables Perl] and [http://doc.perl6.org/language/variables#%24_ Perl 6] documentation about <code>$_</code> (the languages which started this task) and thus I would say at least Erlang, PARI/GP, Python, Standard ML and Unix Shell don't show topic variables (i.e. should be flagged as incorrect/omitted). AIUI <code>$_</code> is used as the default value for functions/language constructs if no argument is provided. But the mentioned languages show variables/consructs that store the most recent result.
::For example compare this Python session
<pre>>>> 1 + 2
3
>>> _
3</pre>
::or this Standard ML (SML/NJ) session
<pre>- 1 + 2;
val it = 3 : int
- it;
val it = 3 : int</pre>
::with this Perl 6 (Rakudo) session
<pre>> 1 + 2
3
> $_
Any()</pre>
::or this Ruby (irb) session
<pre>irb(main):001:0> 1 + 2
=> 3
irb(main):002:0> $_
=> nil</pre>
::There is obviously a difference between both types of special variables. That's why I would like to have a better definition in the task description. --[[User:AndiPersti|Andreas Perstinger]] ([[User talk:AndiPersti|talk]]) 19:18, 11 April 2014 (UTC)