Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: Multiple representations

by zby (Vicar)
on Aug 20, 2004 at 12:59 UTC ( [id://384586]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Multiple representations
in thread Multiple representations

Of course you can express any DSL in Lisp as well as in any other Turing complete language. The question is when it is easy and when not. It is easy to represent XML in Lisp because XML is nearly identical with a part of Lisp - the S-expressions. So every XML document is easily translated to a Lisp data structure with all of it's structure. But you cannot so easily translate the structure of an language that is a bit more than a Context Free Grammar.

By the way the usefull DSL would not be easily translated into the host language, because this makes the DSL a bit trivial.

Replies are listed 'Best First'.
Re^5: Multiple representations
by hhdave (Beadle) on Aug 20, 2004 at 15:35 UTC

    Expressing DSLs in Lisp is quite different from doing so in other languages. In general you can't express DSLs in other languages in any useful sense (only by writing an interpreter in that language or writing a compiler to that language). In Lisp, though, using macros you can modify the language you are using, adapting it it to the problem domain.

    This is easy to do and certainly not trivial (in terms of usefulness). For example, you might need a language for validating the structure of documents. DTDs are one example of these. In Lisp you can implement a series of macros so that you can express DTDs directly in Lisp (I've done this), then the DTD executes as a Lisp program. You just write DTDs using parenthesis instead of the usual syntax.

    Or, consider something like YACC. YACC is a DSL for writing parsers. You could write a parser directly in C, but it would be very tedious. YACC programs (or specs or whatever they're called) are not C programs, though they get translated into C. In Lisp you could just extend the language to implement the semantics of YACC. You wouldn't need a separate YACC program.

    Lisp is different.

    As Guy Steele said: If you give a programmer FORTRAN, he has FORTRAN. If you give a programmer Lisp, he has any language he wants. Turing completeness isn't really the issue. Lisp is really convenient for implementing useful DSLs.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 11:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found