Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have been reading kyle's Context tutorial. Now I just wonder - how much of context is compile-time, how much run-time? Has that been discussed yet?

I ask because

perl -le 'my $f = 1; ($f > 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.

could be resolved at run-time, which isn't, because it barfs at compile-time. This works, however:

perl -le 'my $f = -1; ($f > 0 ? @a : @b ) = ("a", "b", "c"); print "a: + @a\nb: @b"' a: b: a b c perl -le 'my $f = 1; ($f > 0 ? @a : @b ) = ("a", "b", "c"); print "a: +@a\nb: @b"' a: a b c b:

update: diagnostics tells me that

Execution of -e aborted due to compilation errors (#1)
(F) If you assign to a conditional operator, the 2nd and 3rd arguments
must either both be scalars or both be lists. Otherwise Perl won't
know which context to supply to the right side.

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?


In reply to Context: compile-time vs. run-time by shmem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [1nickt]: If 1nickt is the some guy, that's not what he said.
    [GotToBTru]: thepkd might not know about last hour of cb
    [1nickt]: my $x = $aohoaoh->[0]->{' foo'}->[0]->{'bar' }; should work
    [thepkd]: its not $aohoaoh->[0]. its $aohoaoh[0]->{'foo '}. Tried it. Its working. Thnaks
    [thepkd]: Hey 1nickt sorry man. What
    [GotToBTru]: a ref too far ;)
    [thepkd]: Yes this is my first time in cb. Trying to work my way around.
    [JohnCub]: "A ref too far" would make a good title for anyone's perl memoirs
    [thepkd]: Anyways it works with $aohoaoh[0]->{'foo '}[0]->{'bar'}

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (11)
    As of 2016-12-06 13:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:













      Results (105 votes). Check out past polls.