3 ms·
> currency around 2008 so this old 1993 essay wasn't able to use it Embedding languages in Lisp is a concept since around 1962 (Daniel Bobrows METEOR Lisp exte
by lispm 9y ago
> currency around 2008 so this old 1993 essay wasn't able to use it
Embedding languages in Lisp is a concept since around 1962 (Daniel Bobrows METEOR Lisp extension for pattern based string processing). There are a bunch of Lisp articles written before 1980 which describe it and advocate using it.
> Lisp is an interesting programming language for writing an embedded DSL because the custom "mini language" you write looks like other builtin Lisp syntax.
Not really. Lisp is useful for DSL development because it provides the necessary extension features: which allows one to reuse a lot of the Lisp machinery (reader/parser, interpreter, compiler, macros, object-system, memory management, ...).
Common Lisp already comes with DSLs as part of the standard: format strings and LOOP are examples. They actually don't look like Lisp syntax - format strings are radically different and LOOP statements use more algol like syntax.
example for a FORMAT string:
CL-USER 2 > (format t
"~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~}"
(list 1 2 3 4 5))
1, 2, 3, 4, and 5
NIL
example for a LOOP form:
CL-USER 3 > (loop for i in '(1 324 2345 323 2 4 235 252)
when (oddp i)
do (print i)
and collect i into odd-numbers
and do (terpri)
else
collect i into even-numbers
finally
(return (values odd-numbers even-numbers)))
1
2345
323
235
(1 2345 323 235)
(324 2 4 252)
> "metaprogramming" : this is usually describing programs generating other programs either at compile time
metaprogramming means to be able to program on the language level. It has not much to do with program generation. For example in Lisp you can program new syntactic constructs via macros. One can also program the 'reader' which allows one to program the token reader. There are various other ways to program at the language level - the most complex is the Meta-Object Protocol of CLOS, the Common Lisp Object System - which allows one to program the object system system itself in itself.
metaprogramming facilities are tools to develop DSLs.
- jasode 9y ago>Embedding languages in Lisp is a concept since around 1962 You misunderstood what I wrote. I was talking about the terminology PG used, not the concept. PG couldn't time-travel to the future and write "DSL" in his 1993 essay so more readers would instantly understand what he was talking about. > it provides the necessary extension features: which allows one to reuse a lot of the Lisp machinery I agree. The "looks built in" is a characterization that some Lisp programmers (maybe not you) would call the ability to add "new syntax" to Lisp. It's a way of contrasting with something like C++. You can't "extend the C++ language" with new syntax for your custom project unless you fork the GCC or Clang compiler and add new keywords to the parser. All new so-called capabilities to embed a "DSL" has to be done as "functions()" with obvious parentheses to call it. Lisp ("code is data!") doesn't have this hard boundary. >metaprogramming means to be able to program on the language level. I agree. There's parsing/manipulating its own AST as a data structure but "metaprogramming" also has lot of currency usage to describe programs writing programs and the usage of dynamic eval().
- lispm 9y ago> I was talking about the terminology PG used What now is called 'embedded domain specific language' was called 'embedded language' in Lisp. The name is slightly shorter, but the concept is/was the same.
- jasode 9y ago>What now is called 'embedded domain specific language' was called 'embedded language' in Lisp. Exactly! If you do "Ctrl+F" search on PG's essay, you'll see it does _not_ have the phrase "embedded language" nor "embedded domain specific language". What exactly are you nitpicking?
- lispm 9y agoThat he could have used the term 'embedded language', which was used in Lisp decades before he wrote his article. So the article is probably not about embedded DSLs. What he describes is actually extending the language to express the domain - but that does still not mean that the language is 'specific'. It's not necessarily even an embedded language.
- jasode 9y ago>What he describes is actually extending the language to express the domain - but that does still not mean that the language is 'specific'. This appears to be a subjective labeling because "extending the language" is described by some other Lisp programmers as creating a "DSL". Some examples out in the wold: >"Lisp is different, it is a shape shifting creature. It can be made to adapt to any environment [...], one can build a DSL (domain specific language) within Lisp to cater to that domain." From: https://www.quora.com/According-to-Paul-Graham-in-2002-languages-can-be-ranked-in-power-order-and-Lisp-is-the-first-on-that-ranking-Is-this-still-accurate/answer/David-Lin-211 https://www.quora.com/According-to-Paul-Graham-in-2002-langu... >"Extending the syntax the way you're talking about allows you to create domain specific languages." From: https://softwareengineering.stackexchange.com/a/164674 https://softwareengineering.stackexchange.com/a/164674 >", we can extend it in Lisp itself [...] We've just created a very small and limited language for managing to-do lists embedded in Lisp. Such languages are very specific to a particular problem domain and are often referred to as domain specific languages or DSLs." From: http://www.defmacro.org/ramblings/lisp.html http://www.defmacro.org/ramblings/lisp.html What PG is describing may not be a complete and formal DSL according to your definition but others are describing his technique today as writing a <scarequote>DSL</scarequote>.