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

Re: [FWP] syntax barriers?



On Sun, May 13, 2001 at 07:44:03PM -0400, Ronald J Kimball <rjk@linguist.thayer.dartmouth.edu> wrote:
> I guess I don't really understand what the problem is...  You want to
> evaluate a block of user code, separate from other code in the program, but
> you don't want to use eval?

ehrm, that's about correct, yes. I want a perl code sequence that

a) does alter the code as little as possible (eval is major)
b) catches nesting errors as early as possible

"{ ... }" or "do { ... }" already is good at catching most things (as
perl already is good at catching errors early enough). The only thing
it doesn't catch are {} nesting errors. "eval" is obvious, but isn't a
workable solution always.

> > my only grief with that is that i have to duplicate the ugly code around
> > the eval that ensure that the context for the eval is set correctly, that
> > exceptions propagate correctly (and perl does not crash) and lastly there
> > are some issues with eval and utf8 ;)
> 
> What is the context that needs to be set for the eval?

I started thinking about this problem becaue I have a generic _eval
function in one of my programs that can be called in void, list of scalar
context and gives this to the eval "". In theory it would be possible to
rewrite that program to use many single evals, but this is impossible
in the generic case (think lexical variables declared outside the code
sequence), so I was wondering about a good way to tell perl that code
inside a specific "section" must be correctly nested.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |

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