Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^5: Can someone please write a *working* JSON module

by dave_the_m (Monsignor)
on Oct 27, 2021 at 10:47 UTC ( #11138102=note: print w/replies, xml ) Need Help??

in reply to Re^4: Can someone please write a *working* JSON module
in thread Can someone please write a *working* JSON module

I think it spawns a new interpreter right
It definitely doesn't. eval BLOCK just pushes a 'EVAL' context onto the context stack, in a similar way that a sub call pushes a 'SUB' context, and a bare block pushes a 'LOOP_PLAIN' context. A context is just a type flag and a bit of saved state. On normal scope exit, the context is popped and the saved state restored (e.g. @_ restored on return from a sub). On an exception (die, croak etc), the perl interpreter keeps popping contexts (and restoring the saved state in each) until it hits an EVAL context or empties the context stack.

The context stack is what caller() examines (in part).

eval $string has a slow preceding step where it has to call the parser and compile the string into something resembling a sub, then it calls that 'sub' by pushing an EVAL context as with the block case.

Benchmarks show that eval BLOCK has roughly the same overhead as calling a sub with no arguments.


  • Comment on Re^5: Can someone please write a *working* JSON module

Replies are listed 'Best First'.
Re^6: Can someone please write a *working* JSON module
by bliako (Monsignor) on Oct 27, 2021 at 16:17 UTC

    thanks that clarifies it.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138102]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-01-24 06:07 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.