* v0.7: error
** Special forms added
abort error handle
** Library functions added
make-safe-shell-command
** Keywords
Keywords, :like :these, are symbols preceded by a colon. While symbols
evaluate to whatever value they have been set to, keywords evaluate to
themselves.
** Changes to redirection syntax
When you use pipes or angle brackets in your shell commands
(parameters to ~system~, ~with-input-from~, or ~with-output-to~),
write them as keywords :pipe, :gt, :lt, :gtgt. For example,
#+begin_src glotawk
(system "echo" "hi" :pipe "grep" "h")
#+end_src
The make-safe-shell-command function has been added; it's what deals
with these keywords, and if you take input from or send output to
pipes, you need to call this function yourself:
#+begin_src glotawk
(with-input-from "|" (make-safe-shell-command
"echo" "hi" :pipe "grep" "h")
(getline))
#+end_src
It is a wart that the first parameter of with-input-from and
with-output-to is still a string; it should be a keyword.
** abort
The abort special form takes parameters just like sprintf, but it
causes glotawk to dump the current variable bindings and stack trace,
and exit. Yes, we now keep track of the forms we are in the midst of
evaluating, so they can be printed out in case of an abort. This
functionality is not yet used anywhere in glotawk itself, except when
you pass make-safe-shell-command something it doesn't understand and
so it can't prove that what will be run will be safe.
** error and handle
In my experience, conditions with restarts are an important part of
the interactive programming style that Common Lisp enables. These...
are not that, at all, not yet at any rate.
The error form takes parameters just like sprintf, but the resultant
string is an error message. The current thing being evaluated is
abandoned, and indeed everything up the stack, until a handle form (if
any). The handle form is passed the stack, which is just a list of the
forms we were evaluating, innermost to outermost.
For example:
#+begin_src glotawk
(handle (lambda (stack) (printf "Oh well.\n"))
(progn
(+ 1 2 3)
(error "We're outta here! %d" 42)
(printf "This never happens.\n")))
#+end_src
If there is no handler, an error causes an abort.
** glotawk.el
It's janky, but it's a major mode for editing glotawk source files in
Emacs, and it gets the indentation right.
** lacrum added
This is the thing I wanted to write in glotawk: lispy system
configuration management with no dependencies outside the base system.
Unfortunately, at this time, we do depend on a standalone awk, because
POSIX does not yet demand that a conforming awk be able to take the
length of an array, so accordingly busybox awk can't; and toybox
doesn't integrate an awk yet.