Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: The Case for Macros in Perl

by salva (Canon)
on Sep 16, 2014 at 09:44 UTC ( [id://1100719]=note: print w/replies, xml ) Need Help??


in reply to Re: The Case for Macros in Perl
in thread The Case for Macros in Perl

Well, I did it once: Adding macros to Perl5.

Admittedly it was mostly a prove of concept but it shows that technically it is doable... a different matter would be getting p5p to agree on adding the feature and on the macro syntax.

Replies are listed 'Best First'.
Re^3: The Case for Macros in Perl
by BrowserUk (Patriarch) on Sep 16, 2014 at 10:30 UTC
    getting p5p to agree on [anything]

    Obtaining positive opinions are always going to be harder than the skills; though you're in a class of very few in the latter regard.

    Shame it never made it in. That looks very well thought through. Applying an attribute to a subroutine is a) something I'd never thought of; b) (IMO) the perfect way to add it to the syntax,


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      the perfect way to add it to the syntax

      But the issue with macros is not how to indicate the interpreter you are declaring one but how to tell the interpreter the kind of arguments you are expecting.

      In Lisp (and family) you don't have this problem because the language doesn't have a grammar but on Perl, in order to parse something, you need to know where you are.

      The macros in my patch only accept one kind of arguments (expressions) ruling out several interesting usages. For instance, extending the syntax as in try {...} catch {...}.

        The macros in my patch only accept one kind of arguments (expressions) ruling out several interesting usages. For instance, extending the syntax as in try {...} catch {...}.

        I actually consider that a plus. IMO, macros should be limited in both their power and scope. And the in-lining of 'functions' (only) is, for me, the perfect break point.

        The syntax and semantics of functions are very clearly defined and understood. And macros that mirror those are thus easy to learn reason about and use.

        It has been a very long time since I did Lisp, and I was not very good at it then; but I do remember that only thing worse than the (lack of) syntax, was the unholy mess you get into when trying to debug errant Lisp macros. Yuck!


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found