Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

statefulness and Perl

by emilbarton (Scribe)
on Feb 01, 2012 at 13:28 UTC ( #951216=perlquestion: print w/ replies, xml ) Need Help??
emilbarton has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I've recently come to know about SPL ( http://www.clifford.at/spl/) which is a complete stateful language, allowing runtime interruptions and restarts. This language is very interesting but much slower than Perl according to my tests. Is there a way to obtain the same result in running Perl scripts? Are there other complete stateful languages?

Comment on statefulness and Perl
Re: statefulness and Perl
by moritz (Cardinal) on Feb 01, 2012 at 13:39 UTC

    I don't think such a mechanism exist.

    One could try to achieve something like that by dumping core and then restarting that, or by serializing Coroutines, plus all lexicals and package variables, and then inventing some clever way to load them again. But I don't think either approach will work very well, and both would be rather much effort to get working.

    You might have better luck with smalltalk, which seems to support such things better.

Re: statefulness and Perl
by MidLifeXis (Prior) on Feb 01, 2012 at 13:56 UTC

    I wonder if the performance of Perl would be much different once you start adding in the bookkeeping and checkpoints necessary to save state at the various points needed to allow runtime interruptions and restarts.

    Update: Minor grammar fix.

    --MidLifeXis

Re: statefulness and Perl
by eyepopslikeamosquito (Canon) on Feb 01, 2012 at 20:05 UTC
Re: statefulness and Perl
by zentara (Archbishop) on Feb 02, 2012 at 08:51 UTC
    Is there a way to obtain the same result in running Perl scripts?

    I would store all my program's runtime variables in a hash, and write that hash to an sqlite database. When starting up, the program just reads the db and does what it needs to do.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: statefulness and Perl
by emilbarton (Scribe) on Feb 04, 2012 at 07:52 UTC
    I would have thought of core dump too but everything has to be done still for each program you'd like to interrupt. I wonder if SPL can save the state of an embedded running C function, probably not. Anyway it's a nice feature in case of power cut. Thank you for your answers.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951216]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-07-28 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (210 votes), past polls