Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by dave_the_m (Monsignor)
on Oct 27, 2021 at 10:47 UTC ( [id://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.

Dave.

  • 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found