Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by haj (Vicar)
on Oct 26, 2021 at 10:42 UTC ( [id://11138058]=note: print w/replies, xml ) Need Help??


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

I won't argue in favor or against exceptions, but your points contain some inaccuracies.
  • die and croak can deliver objects to $@ quite fine. If you croak with an object, that object is passed to die and you can evaluate that object in $@ as you like. It loses the stacktrace, but then, you don't get a stacktrace by returning error integers/objects as well.
  • The debugger has no problems with eval. You wouldn't know, of course, if you never used it, but then why raise the issue?
  • Also, to clarify something you wrote in Re^4: Can someone please write a *working* JSON module: eval BLOCK does not "spawn a new interpreter".
If you don't like the keyword eval, then you can have try/catch as of Perl 5.34. There are also several CPAN modules offering that, and of course they're all eval wrappers, because that's just the mechanism Perl always had. The point of the modules isn't about using different words, but avoiding the pitfalls with localized $@ (The docs of Try::Tiny give some details).

Replies are listed 'Best First'.
Re^4: Can someone please write a *working* JSON module
by bliako (Monsignor) on Oct 26, 2021 at 12:57 UTC

     If you croak with an object, that object is passed to die and you can evaluate that object in $@ as you like. It loses the stacktrace, I think I just said that.

    The debugger has no problems with eval. i did not say it has, I talked about a hypothetical eyesore, i.e. if it's not seamless, for example line numbers etc. in order to get some input from others who use it to agree or disagree. It would be useful to know your experience on the subject. The process of filing an application to express opinions about something that I don't use but it has an effect on the "croak debate" was taking too long so I thought I say that on the understanding that when the debate police intervenes I will show them the receipt which they can radio it to debate-HQ and get the OK. Sorry but nitpicking is not something I react nicely to.

    eval BLOCK does not "spawn a new interpreter" you are clarifying what exactly? "answering" is the appropriate word as I was asking (I think it spawns a new interpreter right?) after googling it without finding what the exact mechanism is. From experimenting with perlembed I got the impression, that eval_[sp]v are creating a new interpreter. I would really be interested to know the exact mechanism if you want to elaborate your answer?

    Edit: after cooling down, apologies for my tone, to all.

    thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 00:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found