in reply to Solved! I would have expected a syntax error here

Indirect object syntax:
perl -MO=Deparse 1.pl use warnings; use strict; find_symbol(); sub find_symbol { use warnings; use strict; 'to'->got('today'->here(!1)); } 1.pl syntax OK

No argument to here if you remove the !(20180520).

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: I would have expected a syntax error here
by LanX (Saint) on Oct 19, 2018 at 16:50 UTC
    To elabotate further:

    the odd words to today are considered packages, the even ones got here methods.

    Both are not required to exist at compile time.

    It's a variation of new Class arg-list just twice.

    Hence got To (here Today () ) (capitalizing classes for clarity)

    Nb: If the bare words where already pre defined subs, Perl would parse them differently.

    I see two solutions:

    • a possible pragma to forbid indirect method calls (becoming standard in Perl 7)
    • a module which is parsing the op-tree at the CHECK phase warning about undefined packages. (dynamic package creation at runtime is rare)

    the latter could be implemented right away.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      indirect already exists on CPAN:

      >perl -M-indirect -wle "got to here today! (20180520)" Indirect call of method "here" on object "today" at -e line 1. Indirect call of method "got" on object "to" at -e line 1. Can't locate object method "here" via package "today" (perhaps you for +got to load "today"?) at -e line 1.
      >perl -wle "got to here today! (20180520)" Can't locate object method "here" via package "today" (perhaps you for +got to load "today"?) at -e line 1.

      You can put it either into PERL5OPT or just at the top of your code:

      no indirect;

        Corion:

        While I'm going to try to use the yadda operator, I think I'll stick this in my PERL5OPT since:

        1. I'm already using PERL5OPT,
        2. who knows how many of these bombs may be ticking on my hard drive, and
        3. I don't know how long it'll take me to get into the habit of using ...

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.

        Nice ...

        ... but I think it should allow to add new as exception. (couldn't find it)

        There is far too much legacy code using an indirect new as constructor.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice