[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Delayed semantical interpretation



At 05:33 PM 9/22/99 -0400, Michael G Schwern wrote:
>Tied variables and barewords.
>
>A simple:  $foo{this} = bar;  can mean many, many, many things.
>
>First off, is %foo a tied hash?  Is so then it has to be translated
>into the approriate method call (in this case $tied->STORE) and then
>there's all the run-time method lookup fun that goes along with it.
>
>Then, since bar is a bareword it has to check if &bar exists (I don't
>know if this happens at runtime or compile time).  If bar is a
>subroutine name then bar must be called and its context determined
>(that's probably compile time, come to think of it).
>
>Either way, I doubt you can express this in a BNF.

Right.  I think on the variation scale it's the same as an object method; 
it's the same as overloading assignment.  I consider polymorphic methods to 
be 'cheating' as much as eval() for the purposes of my question :-)  (I 
mean, they can do anything.  I'm talking about variation built in to perl.)

At first I thought the interpretation of barewords would qualify, but it 
seems they're resolved at compile time:

         eval 'sub bar () { print "bar\n" }';
         bar;

treats the second line as a string unless I decorate it with () or &.

One could argue that bareword interpretation should be left until run time 
for precisely the (pedantic) scenario above.  Or would it make some 
programs impossible to parse?


--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe