Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Devel::Declare is deprecated, what’s instead? (Keyword::Simple)

by LanX (Saint)
on Aug 02, 2018 at 20:45 UTC ( [id://1219734]=note: print w/replies, xml ) Need Help??


in reply to Devel::Declare is deprecated, what’s instead?

> x $foo, sub {}

I don't really understand what you are trying to achieve, but if Function::Parameters is an option, it's based on Keyword::Simple from the same author, which facilitates the use of Pluggable keywords a lot.

Be warned that keywords need >5.12 and only expand at the start of a statement (like after a semicolon). otherwise we could have a real syntactic macro (i.e. Lisp like) mechanism in Perl.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re: Devel::Declare is deprecated, what’s instead? (Keyword::Simple)

Replies are listed 'Best First'.
Re^2: Devel::Declare is deprecated, what’s instead? (Keyword::Simple)
by RonW (Parson) on Aug 02, 2018 at 23:10 UTC

    In perlapi, the description of KEYWORD_PLUGIN_EXPR implies the pluggable keyword API can support keywords in the middle of an expression. Unfortunately, Keyword::Simple (and modules that use it) doesn't support that. I'm not sure whether Keyword::API supports that.

      I spoke to Lukas - aka "Mauke" - the author of Keyword::Simple in person at various conferences about this and macros in general.

      He said that it's pluggable keys which is not supporting it, and that he thinks that it's due to a bug in the implementation. I'm sure he would love to support it if possible. IIRC he even mentioned a discussion on P5P.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        That's interesting, thank you. I tried to hack Keyword::Simple to return _EXPR, but that expectedly fails because it also creates a single OP_NULL as a statement returned, and that doesn't fly in the expression context. Also, I checked XS::APItest::KeywordRPN that is mentioned in the docs as a reference implementation of a keyword handler, and although it's broken now, it uses _EXPR that supposedly worked at least on 5.13.

        But that leads to another question: I wonder how one compiles perl code to get a optree? If it exists, then Keyword::Simple would be relatively simple to expand, I guess.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found