Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: RFC: Inline::Blocks or inline as a keyword?

by shmem (Chancellor)
on Jul 30, 2018 at 15:05 UTC ( #1219491=note: print w/replies, xml ) Need Help??

in reply to Re: RFC: Inline::Blocks or inline as a keyword?
in thread RFC: Inline::Blocks or inline as a keyword?

Your benchmark is a little too simple. You'll notice the "plain" case and the "do" case run at the same speed.

Of course, but there's that drop for the "do_vars" sub in which the arguments passed to a subroutine are assigned as lexicals inside the "do" block. In that case optimizing away the scope isn't possible, which of course happens with loading pragmas.

Your module implementation is mostly good, but I don't like how you configure it with global variables. What if two modules by different authors try to alter $declmatch? It would be better to allow people to pass these as parameters to import.

Thank you. - Indeed that's work to be done yet (and easy enough): making the package globals into package private lexicals as defaults, which can be overridden by named import parameters. This definitely makes more sense. update: done in the OP.

You don't seem to do anything to cover the case where the inlined sub closes over variables which are declared later than when it is called.

This is on purpose, because that would get me into trouble, into the egg vs. hen problem: I would need to check for outer frames and inspect the nature and existence of variables in those, which are used inside the inlined block. But only constants in closures are suitable for inlining, dynamic closures aren't. So I would need to compile the whole stuff first to munge the source after the fact... no. This module is purely for textual replacement, think cpp.

As a related note, perl4 had the -P command line switch, which caused the source being run through cpp. When did that go away in perl 5? and why?

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^3: RFC: Inline::Blocks or inline as a keyword?
by tobyink (Canon) on Jul 30, 2018 at 18:57 UTC

    The -P switch was deprecated in 5.10 and removed in 5.12. (This was before the current two-stable-versions deprecation cycle.)

    It was replaced with Filter::cpp (though it's only on CPAN, not in core).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2020-02-21 16:20 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (96 votes). Check out past polls.