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

Re: [FWP] Delayed semantical interpretation



>>>>> "MGS" == Michael G Schwern <schwern@pobox.com> writes:

  MGS> Tied variables and barewords.
  MGS> A simple:  $foo{this} = bar;  can mean many, many, many things.

  MGS> First off, is %foo a tied hash?  Is so then it has to be translated
  MGS> into the approriate method call (in this case $tied->STORE) and then
  MGS> there's all the run-time method lookup fun that goes along with it.

interesting choice.

  MGS> Then, since bar is a bareword it has to check if &bar exists (I don't
  MGS> know if this happens at runtime or compile time).  If bar is a
  MGS> subroutine name then bar must be called and its context determined
  MGS> (that's probably compile time, come to think of it).

has to be compile time. otherwise how could you call a sub if it had a
prototype?

  MGS> Either way, I doubt you can express this in a BNF.

the grammar can. tied is normal perl grammar (and much of it can be
expressed in BNF i think. it is the crooks and nannies that make parsing
it so hard). the runtime is definitely hidden. OO perl compares tied
objects to humans who have their bodies invaded by aliens who suck out
their brains and who then control the bodies. :-)

but tied semantics are no more delayed semantics than any method
call. since @ISA can be messed with at runtime, you never know what sub
will get called for a method.

for another answer, how about the range .. op in a scalar context. it
maintains its internal state which affects its runtime behavior. also
regexes with /g and/or \G and pos() have state stored in the
variable. so how you called them in the past affects how they behave in
the future. very delayed semantics IMO.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.

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