Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by tobyink (Canon)
on Aug 01, 2018 at 14:07 UTC ( #1219649=note: print w/replies, xml ) Need Help??


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

I don't know much about source filtering, and perhaps Filter::Util::Call does some whitespace munging, but does this regexp forbid sub declarations from being indented?

qr{^inline\s+sub\s+(\w+)\s*(?:;|\{)}ms

Replies are listed 'Best First'.
Re^2: RFC: Inline::Blocks or inline as a keyword?
by shmem (Chancellor) on Aug 01, 2018 at 15:11 UTC

    Obviously, which is a bug arguably. But then, indented sub declarations are (within my coding standards) closures and such. I will use

    qr{^\s*inline\s+sub\s+(\w+)\s*(?:;|\{)}ms

    if I can be convinced that this is a sensible default for inlineable subs.

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

      Indenting some sub definitions is useful for applying a lexical pragma like no warnings qw(redefine) but then again pragmata wouldn't survive inlining. (Though you could set pragma inside the sub.) I do also use them for grouping code occasionally, but the biggest reason to support indented sub definitions is:

      package Foo { sub bar { ...; } }
        (...) but the biggest reason to support indented sub definitions is:

        Now that's convincing. Well erm... to do things right I'd need to check also what the current package is, for package NAME BLOCK definitions. Then, there could be a inline subroutine(LIST) or even inline subroutine LIST calling an inlineable subroutine imported from elsewhere. I could require B::Deparse and do a coderef2text in that case. Looks like the CAVEATS section needs to be much longer in the pod... or much more work to be done.

        But then, as I mentioned elsewhere in this thread, I'm not at all sure if this package is worth the effort.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-02-29 01:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (128 votes). Check out past polls.

    Notices?