- This talk does not describe a language—yet.
- It describes ideas that I think might be useful.
- Some of these are inspired by XML applications and tools.
- Some inspired by XQuery.
- Some ideas have been implemented in q2.
- XSLT and JSP use XML syntax for both
logic and creating XML. (Verbose, hard-to-read.)
XQuery uses functional syntax for logic,
and XML syntax for element construction. (Less integrated.)
In the Lisp world, we can use S-expressions (SXML).
(No dynamic validation or static typing.)
- LAML maps each HTML tag to a
mirror function with the same name.
Calling a mirror function generates a
- XML namespaces are similar to Common Lisp packages.
- Even uses same syntax: prefix:local-name
- However, namespace is just a URL string.
- Namespace declarations map prefix to a URL.
- Namespace declarations can be lexically nested
(hence must be done after read-time).
(define-namespace html "some-unique-string")
(html:html (html:body (html:p "Hello")))
- XML elements have have named attributes.
- Specify attributes using keyword parameters to constructor functions.
(html:a href: "http://gnu.org/" "GNU")
Attributes can be arbitrary expressions.
- An XQuery expression returns a sequence.
- A sequence is zero or more values.
- Sequences do not nest.
- A one-value sequence is the same as that value.
- Sequences are first-class, but don't have identity.
- Similar to Lisp/Scheme multiple values.
Non-nesting sequences handle common case easier:
list, cons, append are combined.
Non-nesting sequences may be easier for beginners.
E.g. a char and a one-char string are the same.
Symmetry between parameter list and result sequence.
Integrates expressions and
- Since sequences don't nest, we need something that does.
- An array maps integer keys to a value.
- An array is like a function, and is indexed using function call notation.
- Note that a string is a character sequence, not a vector.
- A Scheme <body> is one or more expresions.
Its value is that the of last expression.
Instead, make value of <body> be concatenation of
values of sub-expressions.
Define define, set! etc to return zero values.
If we really need to discard result, use explicit discard.
(let r ((i 0)) ;; R5RS "named let"
(+ 100 i)
(if (< i 5)
(r (+ i 1)))
100 101 102 103 104 105 5 4 3 2 1 0
Add extra constructs to iterate over sequences.
- Mozilla's XUL and Microsoft's XAML let you lay out
GUI applications using XML to describe nested widgets.
- Easy to use, less verbose than Java/C#.
- Integrates poorly with event handlers, awkward repetition.
- Attributes and children are literal, not calculated.
- Element constructors have same benefits and solve problems.
- A row of 10 buttons, one for each digit.
(do ((i 1 (+ i 1)))
((> i 10))
label: (number->string i)
onpress: (lambda () (handle-digit i))))
- In XQuery each parameter is a sequence.
- Suggest instead: Parameter list is a sequence.
- Combines apply and call-with-values.
- Needs syntax to take apart parameter sequence.
- Using patterns (as in ML etc) is convenient.
- Seems promising: see XDuce/CDuce/CQL family.
- Nice to use parentheses for grouping rather than application,
as in ML etc.
- Also nice to use juxtaposition for sequence concatenation;
avoid noise syntax in input not in output.
fun1 a b c
fun2 d e
(fun1 a (b c)
(fun2 d e)