in reply to Re^7: Order of evaluation/interpolation of references
in thread Order of evaluation/interpolation of references

So the only thing proven is that misusing interpolation to eval code with side-effects is a very bad idea!

Maybe, but not illegal. The result is therefore a bug.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re^8: Order of evaluation/interpolation of references

Replies are listed 'Best First'.
Re^9: Order of evaluation/interpolation of references
by LanX (Saint) on Mar 08, 2012 at 02:53 UTC
    And for me it's still not clear which order of interpolation should be named correct in your opinion.

    For me it's intuitively natural to think that "$x$y$z" should act like join("",$x,$y,$z) .

    But print join ("",${X(1)},${Y(2)}); prints

    X Y 22

    because it's well defined that all arguments are evaluated before they are passed to a function.

    So the whole point of this ill idea of returning the same reference with different side effects could only work because interpolation was inconsistent from the beginning.

    Cheers Rolf

      it's well defined that all arguments are evaluated before they are passed to a function.

      If this is right:

      C:\test>perl -E"$\"=''; {my@x; sub X{ push@x,'x';;\@x}}; say qq[@{X()} +@{X()}]" xxx

      Then this is wrong:

      C:\test>perl -E"{my$x; sub X{ $x.='x';\$x}}; say qq[${X()}${X()}]" xxxx

      And vice versa.

      From your other post:

      it's a clear violation ...

      Of what? Your sensibilities? Do you think the same about print "The price is: $obj->tostring()\n";?

      Saying you don't like it, is not the same as it being illegal. And it has always been legal, so it should be consistent.

      From my understanding, interpolating code references into strings is not just legal in Perl6, but further enhanced.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        > "The price is: $obj->tostring()\n";?

        Isn't evaled for me, could you please give me a complete and working snippet?

        Cheers Rolf

Re^9: Order of evaluation/interpolation of references
by LanX (Saint) on Mar 08, 2012 at 02:27 UTC
    The bug is in the design, and I doubt that such an ugly templating system was ever intended, it has look and feel of an accident.

    A real templating system in the core language and PHP wouldn't even exist today.

    I would appreciate if future strictures would kill this possibility in favor of such real templating.

    Cheers Rolf

      such an ugly templating system

      I see nothing in the OP that mentions "templating". I think you assume far, far to much.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        This whole mechanism is a backdoor to execute code while interpolating

        DB<106> print "@{ [`ls`] }" babel-14425MIs emacs1000 keyring-JbFqiG orbit-lanx perlfunc.pod ...

        Thats a clear violation of the line between interpolation (like in s//$x+1/) and evaluation (like in s//$x+1/e)

        Cheers Rolf

        Updated example!