*DB
- A global constant holding the external symbol
{1}
, the database
root. All transient symbols in a database can be reached from that root. Except
during debugging, any explicit literal access to symbols in the database should
be avoided, because otherwise a memory leak might occur (The garbage collector
temporarily sets *DB
to NIL
and restores its value
after collection, thus disposing of all external symbols not currently used in
the program).
: (show *DB)
{1} NIL
+City {P}
+Person {3}
-> {1}
: (show '{P})
{P} NIL
nm (566 . {AhDx})
-> {P}
: (show '{3})
{3} NIL
tel (681376 . {Agyl})
nm (1461322 . {2gu7})
-> {3}
*Dbg
- A boolean variable indicating "debug mode". When non-
NIL
, the
$
(tracing) and !
(breakpoint) functions are enabled, and the
current line number and file name will be stored in symbol properties by
de
, def
and dm
.
: (de foo (A B) (* A B))
-> foo
: (trace 'foo)
-> foo
: (foo 3 4)
foo : 3 4
foo = 12
-> 12
: (let *Dbg NIL (foo 3 4))
-> 12
*Dbs
- A global variable holding a list of numbers (block size scale factors, as
needed by
pool
). It is typically set
by dbs
and dbs+
.
: *Dbs
-> (1 2 1 0 2 3 3 3)
(daemon 'sym . prg) -> fun
(daemon '(sym . cls) . prg) -> fun
(daemon '(sym sym2 [. cls]) . prg) -> fun
- Inserts
prg
in the beginning of the function (first form), the
method body of sym
in cls
(second form) or in the
class obtained by get
ing
sym2
from *Class
(or
cls
if given) (third form). Built-in functions (C-function pointer)
are automatically converted to Lisp expressions. See also expr
, patch
and redef
.
: (de hello () (prinl "Hello world!"))
-> hello
: (daemon 'hello (prinl "# This is the hello world program"))
-> (NIL (prinl "# This is the hello world program") (prinl "Hello world!"))
: (hello)
# This is the hello world program
Hello world!
-> "Hello world!"
: (daemon '* (msg 'Multiplying))
-> (@ (msg 'Multiplying) (pass $134532148))
: *
-> (@ (msg 'Multiplying) (pass $134532148))
: (* 1 2 3)
Multiplying
-> 6
(dat$ 'dat ['sym]) -> sym
- Formats a
date
dat
in
ISO format, with an optional delimiter character sym
. See also
$dat
, tim$
, datStr
and datSym
.
: (dat$ (date))
-> "20070601"
: (dat$ (date) "-")
-> "2007-06-01"
(datStr 'dat ['flg]) -> sym
- Formats a
date
according to the
current locale
. If flg
is non-NIL
, the year will be formatted modulo 100. See also
dat$
, datSym
, strDat
, expDat
, expTel
and day
.
: (datStr (date))
-> "2007-06-01"
: (locale "DE" "de")
-> NIL
: (datStr (date))
-> "01.06.2007"
: (datStr (date) T)
-> "01.06.07"
(datSym 'dat) -> sym
- Formats a
date
dat
in
in symbolic format (DDmmmYY). See also dat$
and datStr
.
: (datSym (date))
-> "01jun07"
(date ['T]) -> dat
(date 'dat) -> (y m d)
(date 'y 'm 'd) -> dat | NIL
(date '(y m d)) -> dat | NIL
- Calculates a calendar date, represented as the number of days since first of
March in the year 0. When called without arguments, the current date is
returned. When called with a
T
argument, the current Coordinated
Universal Time (UTC) is returned. When called with a single number
dat
, it is taken as a date and a list with the corresponding year,
month and day is returned. When called with three numbers (or a list of three
numbers) for the year, month and day, the corresponding date is returned (or
NIL
if they do not represent a legal date). See also time
, $dat
, dat$
, datSym
, datStr
, strDat
, expDat
, day
, week
and ultimo
.
: (date) # Today
-> 730589
: (date 2000 6 12) # 12-06-2000
-> 730589
: (date 2000 22 5) # Illegal date
-> NIL
: (date (date)) # Today's year, month and day
-> (2000 6 12)
: (- (date) (date 2000 1 1)) # Number of days since first of January
-> 163
(day 'dat ['lst]) -> sym
- Returns the name of the day for a given
date
dat
, in the language of the
current locale
. If lst
is given, it should be a list of alternative weekday names. See also week
, datStr
and strDat
.
: (day (date))
-> "Friday"
: (locale "DE" "de")
-> NIL
: (day (date))
-> "Freitag"
: (day (date) '("Mo" "Tu" "We" "Th" "Fr" "Sa" "Su"))
-> "Fr"
(db 'var 'cls ['hook] 'any ['var 'any ..]) -> sym | NIL
- Returns a database object of class
cls
, where the values for
the var
arguments correspond to the any
arguments. If
a matching object cannot be found, NIL
is returned.
var
, cls
and hook
should specify a
tree
for cls
or one of
its superclasses. See also aux
,
collect
, request
, fetch
, init
and step
.
: (db 'nr '+Item 1)
-> {3-1}
: (db 'nm '+Item "Main Part")
-> {3-1}
(db: cls ..) -> num
- Returns the database file number for objects of the type given by the
cls
argument(s). Needed, for example, for the creation of new
objects. See also dbs
.
: (db: +Item)
-> 3
(dbck ['cnt] 'flg) -> any
- Performs a low-level integrity check of the current (or
cnt
'th)
database file, and returns NIL
(or the number of blocks and symbols
if flg
is non-NIL
) if everything seems correct.
Otherwise, a string indicating an error is returned. As a side effect, possibly
unused blocks (as there might be when a rollback
is done before commit
ing newly allocated (new
) external symbols) are appended to the free
list.
: (pool "db")
-> T
: (dbck)
-> NIL
(dbs . lst)
- Initializes the global variable
*Dbs
. Each element in lst
has a
number in its CAR (the block size scale factor of a database file, to be stored
in *Dbs
). The CDR elements are either classes (so that objects of
that class are later stored in the corresponding file), or lists with a class in
the CARs and a list of relations in the CDRs (so that index trees for these
relations go into that file). See also dbs+
and pool
.
(dbs
(1 +Role +User) # (1 . 128)
(2 +CuSu) # (2 . 256)
(1 +Item +Ord) # (3 . 128)
(0 +Pos) # (4 . 64)
(2 (+Role nm) (+User nm)) # (5 . 256)
(3 (+CuSu nr nm str plz ort cty tel mob)) # (6 . 512)
(3 (+Item nr nm sup pr)) # (7 . 512)
(3 (+Ord nr dat cus) (+Pos itm)) ) # (8 . 512)
: *Dbs
-> (1 2 1 0 2 3 3 3)
: (get '+Item 'dbf)
-> (3 . 128)
: (get '+Item 'nr 'dbf)
-> (7 . 512)
(dbs+ 'num . lst)
- Extends the list of database sizes stored in
*Dbs
. num
is the initial offset
into the list. See also dbs
.
(dbs+ 9
(1 +NewCls) # (9 . 128)
(3 (+NewCls nr nm)) ) # (10 . 512)
(de sym . any) -> sym
- Assigns a definition to the
sym
argument, by setting its
VAL
to the any
argument. If the symbol has already
another value, a "redefined" message is issued. When the value of the global
variable *Dbg is non-NIL
, the current
line number and file name (if any) are stored in the *Dbg
property
of sym
. de
is the standard way to define a function.
See also def
, dm
and undef
.
: (de foo (X Y) (* X (+ X Y))) # Define a function
-> foo
: (foo 3 4)
-> 21
: (de *Var . 123) # Define a variable value
: *Var
-> 123
(debug 'sym) -> T
(debug 'sym 'cls) -> T
(debug '(sym . cls)) -> T
- Inserts a
!
breakpoint function call
at the beginning and all top-level expressions of the function or method body of
sym
, to allow a stepwise execution. Typing (d)
at a
breakpoint will also debug the current subexpression, and (e)
will evaluate the current subexpression. The
current subexpression is stored in the global variable ^
. See also *Dbg
, trace
and lint
.
: (de tst (N) # Define tst
(println (+ 3 N)) )
-> tst
: (debug 'tst) # Set breakpoints
-> T
: (pp 'tst)
(de tst (N)
(! println (+ 3 N)) ) # Breakpoint '!'
-> tst
: (tst 7) # Execute
(println (+ 3 N)) # Stopped at beginning of 'tst'
! (d) # Debug subexpression
-> T
! # Continue
(+ 3 N) # Stopped in subexpression
! N # Inspect variable 'N'
-> 7
! # Continue
10 # Output of print statement
-> 10 # Done
: (unbug 'tst)
-> T
: (pp 'tst) # Restore to original
(de tst (N)
(println (+ 3 N)) )
-> tst
(dec 'num) -> num
(dec 'var ['num]) -> num
- The first form returns the value of
num
decremented by 1. The
second form decrements the VAL
of var
by 1, or by
num
. If the first argument is NIL
, it is returned
immediately. (dec 'num)
is equivalent to (- 'num 1)
and (dec 'var)
is equivalent to (set 'var (- var 1))
.
See also inc
and -
.
: (dec -1)
-> -2
: (dec 7)
-> 6
: (setq N 7)
-> 7
: (dec 'N)
-> 6
: (dec 'N 3)
-> 3
(def 'sym 'any) -> sym
(def 'sym1 'sym2 'any) -> sym1
- The first form assigns a definition to the first
sym
argument,
by setting its VAL
's to any
. The second form defines a
property value any
for the first argument's sym2
key.
If any of these values existed and was changed in the process, a "redefined"
message is issued. When the value of the global variable *Dbg is non-NIL
, the current line number
and file name (if any) are stored in the *Dbg
property of
sym
. See also de
and
dm
.
: (def 'b '((X Y) (* X (+ X Y))))
-> b
: (def 'b 999)
# b redefined
-> b
(default var 'any ..) -> any
- Stores new values
any
in the var
arguments only if
their current values are NIL
. Otherwise, their values are left
unchanged. default
is used typically in functions to initialize
optional arguments.
: (de foo (A B) # Function with two optional arguments
(default A 1 B 2) # The default values are 1 and 2
(list A B) )
-> foo
: (foo 333 444) # Called with two arguments
-> (333 444)
: (foo 333) # Called with one arguments
-> (333 2)
: (foo) # Called without arguments
-> (1 2)
(del 'any 'var) -> lst
- Deletes
any
from the list in the value of var
, and
returns the remaining list. (del 'any 'var)
is equivalent to
(set 'var (delete 'any var))
. See also delete
, cut
and pop
.
: (setq S '((a b c) (d e f)))
-> ((a b c) (d e f))
: (del '(d e f) 'S)
-> ((a b c))
: (del 'b S)
-> (a c)
(delete 'any 'lst) -> lst
- Deletes
any
from lst
. If any
is
contained more than once in lst
, only the first occurrence is
deleted. See also delq
, remove
and insert
.
: (delete 2 (1 2 3))
-> (1 3)
: (delete (3 4) '((1 2) (3 4) (5 6) (3 4)))
-> ((1 2) (5 6) (3 4))
(delq 'any 'lst) -> lst
- Deletes
any
from lst
. If any
is
contained more than once in lst
, only the first occurrence is
deleted. ==
is used for comparison
(pointer equality). See also delete
,
asoq
, memq
and mmeq
.
: (delq 'b '(a b c))
-> (a c)
: (delq (2) (1 (2) 3))
-> (1 (2) 3)
(diff 'lst 'lst) -> lst
- Returns the difference of the
lst
arguments. See also sect
.
: (diff (1 2 3 4 5) (2 4))
-> (1 3 5)
: (diff (1 2 3) (1 2 3))
-> NIL
(dir ['any]) -> lst
- Returns a list of all filenames in the directory
any
. Names
starting with a dot '.
' are ignored. See also cd
and info
.
: (filter '((F) (tail '(. c) (chop F))) (dir "src/"))
-> ("main.c" "subr.c" "gc.c" "io.c" "big.c" "sym.c" "tab.c" "flow.c" ..
(dirname 'any) -> sym
- Returns the directory part of a path name
any
.
See also path
.
: (dirname "a/b/c/d")
-> "a/b/c/"
(dm sym . fun|cls2) -> sym
(dm (sym . cls) . fun|cls2) -> sym
(dm (sym sym2 [. cls]) . fun|cls2) -> sym
- Defines a method for the message
sym
in the current class,
implicitly given by the value of the global variable *Class
, or - in the second form - for the
explicitly given class cls
. In the third form, the class object is
obtained by get
ing sym2
from *Class
(or cls
if
given). If the method for that class existed and was changed in the process, a
"redefined" message is issued. If - instead of a method fun
- a
symbol specifying another class cls2
is given, the method from that
class is used (explicit inheritance). When the value of the global variable *Dbg is non-NIL
, the current line number
and file name (if any) are stored in the *Dbg
property of
sym
. See also OO Concepts
,
de
, undef
, class, rel, var, method, send and try.
: (dm start> ()
(super)
(mapc 'start> (: fields))
(mapc 'start> (: arrays)) )
: (dm foo> . +OtherClass) # Explicitly inherit 'foo>' from '+OtherClass'
(do 'flg|num ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any
- Counted loop with multiple conditional exits: The body is executed at most
num
times (or never (if the first argument is NIL
), or
an infinite number of times (if the first argument is T
)). If a
clause has NIL
or T
as its CAR, the clause's second
element is evaluated as a condition and - if the result is NIL
or
non-NIL
, respectively - the prg
is executed and the
result returned. Otherwise (if count drops to zero), the result of the last
expression is returned. See also loop
and for
.
: (do 4 (printsp 'OK))
OK OK OK OK -> OK
: (do 4 (printsp 'OK) (T (= 3 3) (printsp 'done)))
OK done -> done