[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how expressive are they?



--- Trevor Blackwell <tlb@anybots.com> wrote:
> What I'd like to see is an example of a program, in
> a language with easy
> syntax for assignment and blocks, where rewriting it
> without any
> user-defined macros would be similarly painful.

Language: Scheme
Syntax for assignment: not used
Syntax for blocks: trivial macro to redefine lambda as
fn

Macro: pattern matching

Use: Writing XML transformations using an easy to read
and easy to write visual notation.

Exmple (from the WebIT! documentation):

Transforms a marked-up book of poems into a load of
HTML:

(xml-macro book
     (xml-rules
      ((_ title: bt
          (poem title: t poet: a tag: m
                (stanza (line l1) (line l) ...) ...)
...)
       (xml-template
          (h4:html
           (h4:head (h4:title bt))
           (h4:body
             (h4:h1 bt)
             (h4:p) "Table of Contents:"
             (h4:ul (h4:li (h4:a h4:href:
(string-append "#" m) t)) ...)
             (h4:div (h4:p) (h4:a h4:name: m)
(h4:strong t) (h4:br) (h4:em a)
                     (list (h4:p) l1 (list (h4:br) l)
...) ...) ...))))))


Rewrite that as succinctly and clearly in
Perl/Smalltalk/your-favourite-PL

Noel

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com