Hyper Lisp Markup Language
HLML is a expirmental new markup language/scripting environment
First, some basic concepts of writing code in a lisp:
3~”hello”~ evaluate to themselves, and are basic atoms.
fare the “symbol”
f. Evaluating a symbol causes it to be looked up in the enviornment and replaced with their definiton.
(f 2 3)is the list containing
3. Evaluating this list causes
fto be interpreted as a function, and
3, to be interpreted as arguments.
(f 2 3)is equivalent to writing
f(2,3)in most languages.
(+ 1 2)evaluates to
This means you cannot write the list consisting of 1,2,3 as
(1 2 3), as when evaluated, this will treat
1as a function, which it’s not, and will thus cause a type error.
If you want to produce a list instead of calling a function, use the
(list 1 2 3)evaluates to
(1 2 3).
This is were things get lispy. There are is a builtin form called
quotethat prevents its arguments from being evaluated. So evaluating
x, regardless of what
xis defined as, or if it’s defined at all. This can be used to make lists:
(quote (1 2 3))is equivalent to
(list 1 2 3), as quote stops the evaluation, so
1does not get treated as a fucntion. However
(quote (1 (+ 1 1) 3))is not equivalent to
(list 1 (+ 1 1) 3).
quotestops all evaluation, so the former evalutes to
(1 (+ 1 1) 3), whereas normal functions evaluate their aguments, producing:
(1 2 3).
In addition to
quote, there are the forms
unquote, shortcutted to
`and ~,~ respectivly. These allow you to conditionally resume evaluation. For example:
`(1 ,(+ 2 3) 3)evaluates to
(1 5 3).
- Useful builtins:
define-> Defines a variable:
(define x 3) (+ x 2)evaluates to
define-> Define a fucntion
(define (add1 x) (+ 1 x)) (add1 3)evaluates to
list-> produce a list
map-> maps a function over a list:
(map add1 (list 1 2 3))evaluates to
(2 3 4)
The Markup Language
HLML looks fairly similar to
HTML but using lisp syntax. So to use the
b tag, you’d write:
(b Here is my text in bold). Tag attributes are specified by following a tag with the following
(attr (name value) ...), for example:
(a (attr (href "google.com")) Link to google).
Scripting support is enabled by the
script tag. Scripts can create
hlml objects by just making
hlml file is provided in
hlml.rkt is a prototype implementation of the language.
To use it, run
racket hlml.rkt <file>, which will evaluate the
script calls and produce the
racket hlml.rkt -o <file> to compile
html, to view in a browser.
Features remaining to implemented:
scripts not allowed to mutate the page yet. Big feature.
Attribute syntax: Does this syntax work nicely, or is it annoying?
(Maybe it should be
((a (href "example.com")) click))