DSLs, system variable wish, conditional evaluation

Started by Tim Johnson, September 25, 2009, 12:06:04 PM

Previous topic - Next topic

Tim Johnson

Three topics, all interrelated.

Consider the following expression:

(ml '(
(table(& bgcolor "white" border 1)
(tr (F th (font(& color "darkred") "View File"))
(F th "Log Dir"))
(tr(,(select-file filelist))
(form (& method POST action (, cgi:path-thru))
(td(& valign top)
(F select (& name logdir size (,(length dirlist)))
       (, dirlist))(br)
(input (& type submit value "Log Directory"))))))) 1)

The 'ml function is the default functor for a context that I am writing. It is based

on http://www.newlisp.org/index.cgi?page=S-expressions_to_XML">http://www.newlisp.org/index.cgi?page=S ... ons_to_XML">http://www.newlisp.org/index.cgi?page=S-expressions_to_XML and is extended

to html, with conditional evaluation, attribute lists and optional 'oneline' mode. (as

opposed to nesting)

Now let's consider the following subexpression:
(,(select-file filelist))

1)Imagine it looking like this:(,(select-file filelist $DEPTH))
Where $DEPTH is a system variable that contains the 'depth' or 'level' of the

sub-expression.

2)Note the comma that starts the sub-expression. Ripped off from CL, tells 'ml

to evaluate the following expression. In rebol the 'compose function will signal

the interpreter to evaluate anything in a parens. (rebol uses a block structure where

expressions are delimited by opening and closing square brackets)

I find the DSL (domain-specific language) paradigm very useful. My two "wishes",

the $DEPTH variable and conditional evaluation signal would be useful to me. I wonder

if they would have other uses.

Comments are welcome.

Thanks

Tim
Programmer since 1987. Unix environment.

cormullion

#1
Your $Depth idea reminds me of the number you see when you using the debugger - wonder if it's the same, and would be easy to adapt?

Tim Johnson

#2
Quote from: "cormullion"Your $Depth idea reminds me of the number you see when you using the debugger - wonder if it's the same, and would be easy to adapt?

I would guess that $DEPTH would be easy to adapt. The lisp approach to syntax

parsing is devilishly simple. All hail John McCarthy! And I (think) would be basically

easily translated from the stack depth.

thanks

tim
Programmer since 1987. Unix environment.

TedWalther

#3
Quote from: "Tim Johnson"
Quote from: "cormullion"Your $Depth idea reminds me of the number you see when you using the debugger - wonder if it's the same, and would be easy to adapt?

I would guess that $DEPTH would be easy to adapt. The lisp approach to syntax

parsing is devilishly simple. All hail John McCarthy! And I (think) would be basically

easily translated from the stack depth.

thanks

tim


Sounds like you are asking for reader macros.  I've been meditating on it, and think I could implement it in newlisp itself, but I'd have to replace the default newlisp binary with a new interpeter for it to work.  An extra layer of indirection.  Yuck.



Ted
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.