From: D Herring
Subject: Re: designing a Lisp-like language
Date: 
Message-ID: <g_2dnZx1t92_FW3bnZ2dnUVZ_jydnZ2d@comcast.com>
Stefan Ram wrote:
>   I would like to embed a Lisp-like language into a
>   text formatter, so that, for example
> 
>       �The value is (+ 2 3).�
> 
>   yields
> 
>       �The value is 5.�

There are already numerous variants on this (e.g. cl-emb or the 
various HTML template packages[1]).

For my own, I used <(angles and parentheses)>.
Benefits:
- looks like both HTML/XML and Lisp
- has parentheses ready for the Lisp reader
- rarely used, visually pleasing pattern

To print simple/common values, I defined a few Perl/shell-style functions.

   <($ scalar)> is roughly (princ scalar)
   <(@ array)> prints each element of the array, separated by IFS
   <(% key table)> prints (gethash key table)
   <(tag+)> prints "<("
   <(tag-)> prints ")>"


Later,
Daniel

[1]
http://common-lisp.net/project/cl-emb/
http://random-state.net/files/trivial-template.lisp
http://weitz.de/html-template/
From: Ville Oikarinen
Subject: Re: designing a Lisp-like language
Date: 
Message-ID: <Pine.LNX.4.56L0.0709190915250.9730@localhost>
On Tue, 18 Sep 2007, D Herring wrote:

> There are already numerous variants on this (e.g. cl-emb or the 
> various HTML template packages[1]).
> 
> For my own, I used <(angles and parentheses)>.
> Benefits:
> - looks like both HTML/XML and Lisp
> - has parentheses ready for the Lisp reader
> - rarely used, visually pleasing pattern
> 
> To print simple/common values, I defined a few Perl/shell-style functions.
> 
>    <($ scalar)> is roughly (princ scalar)
>    <(@ array)> prints each element of the array, separated by IFS
>    <(% key table)> prints (gethash key table)
>    <(tag+)> prints "<("
>    <(tag-)> prints ")>"

Here's another strategy for comparison, the "html" language created with 
my ngrease metalanguage (http://ngrease.sourceforge.net):

html {
  body {
    p {
      This is normal text, because all elements are childless.
      This i {i element} can easily be interpreted as formatting, 
      because it has children, the text to show in italics.
      If an element has one child, you can also use a colon so
      here you will see i:italics and b:bold.
    }
    p {
      If colons or parentheses are needed in normal text, they must
      be escaped in quotes like "this:" "{" "(" and here is a "quote:"
      "\"" or '"'
    }
    p {
      The html, p and i tags have meaning for the user level i.e. the 
      ngrease version of the html language, but the dollar symbol has
      meaning for the ngrease metalanguage. So if this whole html element
      is evaluated by ngrease before getting transformed by the html 
      language, you will see 3 "here:"
      $:+ {1 2} 
    }
  }
}

- Ville Oikarinen