Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Re: Macros, LFSPs and LFMs

by demerphq (Chancellor)
on Jun 15, 2003 at 08:47 UTC ( [id://266010]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Macros, LFSPs and LFMs
in thread Macros, LFSPs and LFMs

Ok, I dont diasgree with your general points here. And I wasnt using VB as an example of good macro system. Just pointing out that it isn't a indication that a language is FSP. :-)

One issue I have however is that I dont think many people would consider parse tree access a necessary feature of a macro langauge. Yes of course it makes a lot of sense, but I dont think that many people would instantly think of parse tree access if you mentioned macros to them. And to a certain extent I think that macros that do have this type of power arent really macros any more, but rather some part of the language that provides some behaviour (and more no doubt) that traditionally was left to a macro preprocessor. For instance, would you consider an inline sub to be a macro? Howabout a Template Class?

My point here is that the use of macros for language extension is indiciative that the language is missing needed features at an integrated level. If LW and co want to provide a general solution that involves very macro like things that have oodles of power and flexibility then fine, but I think the term "macro" is a loaded one and using it when you really mean "macro like subroutines with introspective features such as parse tree access" is inclined to lead towards confusion.

I think also that in general that macros arent used for language extension. I think more often than not they are used for inlining and conditional compilation. Consider Aristotle made some points about Assert(). This example however is only a combination of inlining and conditional compilation, and as far as a source filter goes wouldnt be that hard to write (with a few minor constraints). As for Templating Ala C++ Template Classes, this also isnt particularly difficult to do in perl (albeit a touch klunky).

Granted that real language extension like Switch and try{}catch{}, is hard. But to me the issue with these is that they are missing at all, not that Perl is missing a sufficiently powerful mechanism to write them ourselves. While I personally think that providing a general extend the language mechanism with macro like features to be a powerful approach, I can only wonder what the result will be. For instance with(). I think that because LW for some reason doesnt like it (no doubt for good reasons), we will end up with a number of modules providing it with slightly different syntax. Likewise for other features the language is missing. Eventually we could find that this langauge extension facility actually undermines the cohesion of the overall codebase. (I have 5 Perl6 programs, and I need 40 different syntax extensions installed for them to compile because each one uses a different set.) I look forward to seeing what happens.


---
demerphq

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Replies are listed 'Best First'.
Re^4: Macros, LFSPs and LFMs
by adrianh (Chancellor) on Jun 16, 2003 at 01:19 UTC
    Ok, I dont diasgree with your general points here. And I wasnt using VB as an example of good macro system. Just pointing out that it isn't a indication that a language is FSP. :-)

    Fair enough, but the FSP/LFM article was specifically discussing macros of a Lispish variety ;-)

    One issue I have however is that I dont think many people would consider parse tree access a necessary feature of a macro langauge.

    Depends on your background. If you use C/C++/C/etc. a macro is something like CPP. If you use Lisp/Scheme/etc. it means a transformation of the parse tree. Lisp has had macros since the mid-sixties so for many people who were around back then, or have spent time using similar languages, that's what a programming language macro is all about.

    Of course, if your an Outlook user a macro just means mailing everybody you know a virus :-)

    My point here is that the use of macros for language extension is indiciative that the language is missing needed features at an integrated level.

    Not always. There are always domain specific language extensions. These, by their very nature, are niche so should not be built into the core language.

    There is also the problem all language implementors have - the lack of 20/20 foresight. You can't tell what the next great programming paradigm is going to be - so it's a good idea to build in a generic mechanism so people can add them in at a later date.

    For example: When Lisp (back in the late fifties) and Pop-11 (back in the early eighties) were created object-oriented programming wasn't the cool thing on the block it is now.

    Because both of these languages are capable of redefining language syntax and semantics they both could create complete OO systems (CLOS and ObjectClass amongst others) without having to go back to the drawing board.

    Imagine how different it would have been if in Perl4 you could have added objects by doing use Perl::Objects. That's what Lisp and Pop-11 developers could do.

    At the moment there are new (meaning that they have been around for years and people are finally taking notice of them) things like Aspect Oriented Programming, Design by Contract, Constraint Based Programming, etc. appearing on the horizon.

    I want to be using a language that can take these new ideas and steal all of the best bits without having to re-write everything from scratch. That's what a good macro system gives you. You have a language infrastructure that you can extend to your hearts content.

    I think also that in general that macros arent used for language extension. I think more often than not they are used for inlining and conditional compilation. Consider Aristotle made some points about Assert(). This example however is only a combination of inlining and conditional compilation, and as far as a source filter goes wouldnt be that hard to write (with a few minor constraints).

    Minor constraints are annoying or worse. As soon as you start reducing the expressiveness of a language to make implementation easier you're on a slippery slope.

    There is also the problem of that multiple source filters don't play well together.

    While I personally think that providing a general extend the language mechanism with macro like features to be a powerful approach, I can only wonder what the result will be. For instance with(). I think that because LW for some reason doesnt like it (no doubt for good reasons), we will end up with a number of modules providing it with slightly different syntax. Likewise for other features the language is missing. Eventually we could find that this langauge extension facility actually undermines the cohesion of the overall codebase.

    The community tends to find the good. In the same way Perl coders focused on DBI for database connectivity, Lisp coders focused on CLOS for writing OO code.

    I'm sure that there will be some features that get implemented multiple time. Just like there seem to be more templating modules than PAUSE ids on CPAN. The community will quickly find the ones that give them value and give the others short shrift.

    This is the thing that takes a little getting used to. A new piece of syntax is no longer a "big thing". You don't have to go and learn lots of deep magic so you can rebuild your compiler from scratch. You just load some code.

    I look forward to seeing what happens.

    Me too :-)

Log In?
Username:
Password:

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

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

    No recent polls found