Quote:
For example, in "C" there are no anonymous references (well, there is, AFAIR, one case when an anonymous pointer to structure can be used in C99) while in Perl there are anonymous references that can be used "everywhere". In "C" there are no closures while in Perl there are. In "C" itself you can't add a piece of code on the fly - rather, you can, but you need to know what compiler to use, so it's not portable, while in Perl/Python/Java/Ruby you can do it portably. All these features, or lack thereof, drastically affect the way programs are developed in the corresponding languages. For example, you need something like XML for "C", and you don't need it for Perl - Perl is self-sufficient to pass data between Perl programs, i.e. data can be passed in Perl format and it's the easiest way to do it. |
Quote:
'eval' can be used as simple and good enough macro approximation: Code:
sergei@amdam2:~/junk> cat -n perl_macro.pl |
Quote:
The key point is not that it can simply be done in any language, that's a mundane fact. The real key point is that the language you choose can have a profound impact on how easy it is for you to do it. |
For the lisp-ish side of Perl: Mark Jason Dominus' really great book "Higher Order Perl" is available online:
http://hop.perl.plover.com/book/ |
Quote:
Code:
macro(@my_array); Code:
@my_array = (1, 2, 3, ...) Code:
macro('@my_array'); |
Quote:
Code:
'macro(@my_array)' OTOH, there are Perl modules of source filter kind which do all kinds of text substitution. One can read this: http://perldoc.perl.org/perlfilter.html . I haven't written a filter of such kind myself, but there is a number of very handy filters written by others. With those filters the code will look like Code:
macro(@my_array) |
All times are GMT -5. The time now is 04:37 PM. |