<?xml version="1.0" encoding="windows-1252"?>
<node id="738778" title="Context: compile-time vs. run-time" created="2009-01-25 10:09:02" updated="2009-01-25 10:09:02">
<type id="115">
perlquestion</type>
<author id="510280">
shmem</author>
<data>
<field name="doctext">
&lt;p&gt;I have been reading [kyle]'s [id://738558].
Now I just wonder - how much of &lt;i&gt;context&lt;/i&gt; is compile-time, how much run-time? Has that been discussed yet?
&lt;/p&gt;
&lt;p&gt;
I ask because
&lt;/p&gt;
&lt;code&gt;
perl -le 'my $f = 1; ($f &gt; 0 ? @a : $a ) = ("a", "b", "c")'
Assignment to both a list and a scalar at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
&lt;/code&gt;
&lt;p&gt;could be resolved at run-time, which isn't, because it barfs at compile-time. This works, however:&lt;/p&gt;
&lt;code&gt;
perl -le 'my $f = -1; ($f &gt; 0 ? @a : @b ) = ("a", "b", "c"); print "a: @a\nb: @b"'
a: 
b: a b c
perl -le 'my $f = 1; ($f &gt; 0 ? @a : @b ) = ("a", "b", "c"); print "a: @a\nb: @b"'
a: a b c
b: 
&lt;/code&gt;
&lt;p&gt;update: [doc://diagnostics] tells me that&lt;/p&gt;
&lt;blockquote&gt;&lt;small&gt;
Execution of -e aborted due to compilation errors (#1)
&lt;blockquote&gt;
    (F) If you assign to a conditional operator, the 2nd and 3rd arguments&lt;br&gt;
    must either both be scalars or both be lists.  Otherwise Perl won't&lt;br&gt;
    know which context to supply to the right side.&lt;br&gt;
&lt;/blockquote&gt;
&lt;/small&gt;&lt;/blockquote&gt;
&lt;p&gt;which looks like establishing the context for the RHS is a compile-time thing. Is there such a thing as runtime context resolving, at all?&lt;/p&gt;</field>
</data>
</node>
