DSLs, system variable wish, conditional evaluation

Pondering the philosophy behind the language
Locked
Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

DSLs, system variable wish, conditional evaluation

Post by Tim Johnson »

Three topics, all interrelated.
Consider the following expression:

Code: Select all

(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 ... ons_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:

Code: Select all

(,(select-file filelist)) 
1)Imagine it looking like this:

Code: Select all

(,(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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by 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?

Tim Johnson
Posts: 253
Joined: Thu Oct 07, 2004 7:21 pm
Location: Palmer Alaska USA

Post by Tim Johnson »

cormullion wrote: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

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Post by TedWalther »

Tim Johnson wrote:
cormullion wrote: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

Locked