Well, that's rather the question, isn't it? I guess at the very least I'd like to be able to write something that looks and feels like suroutine but is inlined into the code that "calls" it, thus avoiding the overhead of a real subroutine call:
macro beep ($) {
print LOG "BEEP: $_[0]\n";
}
Then I can beep() to my heart's content without killing my program with the subroutine overhead.
But that's just the start. Reading "On Lisp" made me realize that an expressive macro system can do more than just provide a fast, clean alternative to subroutine calls. How would this work in Perl, which is a lot more varied than Lisp? I'm not at all sure.
-sam
| [reply] [d/l] |
I think you will be able to do this in Perl 6:
sub beep ($text) is inline { print $LOG "BEEP: $text\n"; }
I've seen examples of this (is inline) for custom operators on the perl6-language list.
| [reply] [d/l] |
Sounds good. So how do we get it in Perl 5? I live in the present and Perl 6 just seems like a nice daydream most days.
-sam
| [reply] |
Keep in mind though Lisp is somewhat slow to begin with. I'd wager that mundane Perl coding would still beat profiled Lisp.
-Lee
"To be civilized is to deny one's nature."
| [reply] |
I wouldn't bet that. A good compiled lisp, and there are a number of them, will beat the pants off of perl for many things. (Regular expressions being a notable exception)
| [reply] |
Hello. One of the Monastery's resident Common Lisp users here. I'd take that wager in a second. With the exception of certain things that Perl is explicitly optimized for (like regexes, string processing and such) I'd expect a quality Lisp (e.g. Lispworks, Allegro, CMUCL) to do much better. For example, I have considerable code doing numerical computations in Lisp, and it's typically not even worth rewriting it in (for example) C to attempt to get a speed improvement.
| [reply] |
| [reply] |