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

Re^2: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments

by tobyink (Abbot)
on Nov 10, 2013 at 11:35 UTC ( #1061898=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments
in thread Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments

Perl without its internal 'magic' implementation is essentially no longer Perl.

Agreed. But I don't think the intention is for these to not work. Merely for a Perl implementation that is able to optimize particular sections of code that don't need magic. (Perhaps using a no magic; pragma as a hint to the compiler of what sections it can optimize.)

That certainly seems a worthy thing to work on.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name


Comment on Re^2: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments
Download Code
Re^3: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments
by Will_the_Chill (Pilgrim) on Nov 10, 2013 at 12:36 UTC
    tobyink,

    You are absolutely correct in every regard.

    People have been talking about a "no magic;" pragma for years:

    one more in support for "no magic" pragma, Anthony Baxter to Tom Christiansen, Tue 04 Mar 1997

    You will note, hopefully happily so, this is already codified in The Low-Magic Perl Commandments:

    LMPC #12. Thou Shalt Use Pragmata To Mark Magic Level Of Code (“use magic;” & “no magic;”)

    Thank you for your moral support! :-)

    Perling,
    ~ Will the Chill
Re^3: Perl 5 Optimizing Compiler, Part 9: RPerl.org & The Low-Magic Perl Commandments
by Jenda (Abbot) on Nov 11, 2013 at 14:25 UTC

    The catch is that as soon as that section uses a parameter or a global, it has no chance to know whether there will be any magic!

    Does

    sub addOne { my ($num) = @_; return $num + 1; }

    need any magic? No? So what happens if I pass the subroutine a tie()d variable?

    I'd like to ask the OP to restrict himself to a recent version of English if he decides to reply. His attempts at old English are funny for two sentences, boring for ten and right away annoying for longer posts.)

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      Hi Jenda,

      My only use of old English is The Book Of RPerl, and perhaps to a trivial degree the use of "thou shalt" and "thou shalt not" in The Low-Magic Perl Commandments. Just for you, just in this post, I'll replace "Thou Shalt Not" with "DON'T". :-)

      To address your concerns, globals are not allowed and tied variables are not allowed.

      LMPC #17. DON'T Use Dynamic-Type Data, Auto-Vivification, Or Tied Variables

      LMPC #19. DON'T Use Private Dynamic-Scope (“local”), Private Persistent Lexical-Scope (“state”), Global, Or Package Variables (“our”)

      Does that answer your questions?

      Thanks,
      ~ Will

        No it doesn't. The point is that you can't compile a piece of code without magic, because the magic may come from the outside. So even if YOU do follow all those commandments, someone else might not. The result is that even if you do follow all those commandments to the letter, the amount of code that may be safely compiled in a no-magic mode is gonna be fairly small.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (17)
As of 2014-08-01 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (17 votes), past polls