3 ms·
I'll give you macros, but if you define DSLs as "chained methods", many languages have DSL supports. The author's talking about Perl's support for mangling the
by chromatic 14y ago
I'll give you macros, but if you define DSLs as "chained methods", many languages have DSL supports. The author's talking about Perl's support for mangling the language itself through third party modules.
- knighthacker 14y agoExactly. MooseX::Declare is a good example.
- rb2k_ 14y agoWhat does Perl have in that regard that Ruby hasn't? Ruby also has open classes and you can chain and modify any of the base classes, be it "String" or "Object". I don't know anything like "MooseX", but that might be because Ruby actually has a somewhat working object system.
- chromatic 14y agoPerl lets you add new language keywords which take effect during the parse phase.
- klibertp 14y agoSo, basically, Perl has macros? REAL macros? Like, say, in Lisps? Could I, for example, make fully inlined merge sort, as demonstrated a couple days ago here by a post from Racket blog? Now I'm curious.
- itsreallynotme 14y agoPerl doesn't have real macros. It has a pretty neat, get you most of the way there aftermarket bolt on. Kind of like its object system. Similarly, you can do a lot with it. But it ain't Lisp macros.
- btilly 14y agoSort of. Perl has support for something like reader macros. See http://search.cpan.org/~zefram/Devel-Declare-0.006011/lib/Devel/Declare.pm http://search.cpan.org/~zefram/Devel-Declare-0.006011/lib/De... for details. One could, in theory, build something like Lisp macros using it, but I don't think that anyone has.
- chromatic 14y agoPerl 5's parser manipulation doesn't go as far as manipulating an AST, yet. I would like that, but Lisps still have a strong advantage there.
- UncleOxidant 14y agoSure, but the intent of the author seems to be to say that the language can be molded in ways that make it easy to apply in specific domains. Whether that's with macros or with a DSL-ish approach you're pretty much achieving the same end result. Ruby's blocks make it fairly easy to create DSLs that look like you've actually changed the underlying language in some way - Rails makes heavy use of these features, for example.