- *Tmp
- A global variable holding the temporary directory name created with tmp. See also*Bye.
: *Bye
-> ((saveHistory) (and *Tmp (call 'rm "-r" *Tmp)))
: (tmp "foo" 123)
-> "/home/app/.pil/tmp/27140/foo123"
: *Tmp
-> "/home/app/.pil/tmp/27140/"
 
- *Tsm
- A global variable which may hold a cons pair of two strings with escape
sequences, to switch on and off an alternative transient symbol markup. If set,
printwill output these sequences to
the console instead of the standard double quote markup characters. An easy way
to switch on transient symbol markup is loading "@lib/tsm.l".
: (de *Tsm "^[[4m" . "^[[24m")   # vt100 escape sequences for underline
-> *Tsm
: Hello world
-> Hello world
: (off *Tsm)
-> NIL
: "Hello world"                  # No underlining
-> "Hello world"
 
- +Time
- Class for clock time values (as calculated by time), a subclass of+Number. See also Database.
(rel tim (+Time))  # Time of the day
 
- T
- A global constant, evaluating to itself. Tis commonly returned
as the boolean value "true" (though any non-NILvalues could be
used). It represents the absolute maximum, as it is larger than any other
object. As a property key, it is used to store Pilog clauses, and inside Pilog clauses it is the
cut operator. See alsoNILand
and Comparing.
: T
-> T
: (= 123 123)
-> T
: (get 'not T)
-> ((@P (1 (-> @P)) T (fail)) (@P))
 
- This
- Holds the current object during method execution (see OO Concepts), or inside the body of a withstatement. As it is a normal symbol,
however, it can be used in normal bindings anywhere. See alsoisa,:,=:,::andvar:.
: (with 'X (println 'This 'is This))
This is X
-> X
: (put 'X 'a 1)
-> 1
: (put 'X 'b 2)
-> 2
: (put 'Y 'a 111)
-> 111
: (put 'Y 'b 222)
-> 222
: (mapcar '((This) (cons (: a) (: b))) '(X Y))
-> ((1 . 2) (111 . 222))
 
- (t . prg) -> T
- Executes prg, and returnsT. See alsonil,prog,prog1andprog2.
: (t (println 'OK))
OK
-> T
 
- (tab 'lst 'any ..) -> NIL
- Print all anyarguments in a tabular format.lstshould be a list of numbers, specifying the field width for each argument. All
items in a column will be left-aligned for negative numbers, otherwise
right-aligned. See alsoalign,centerandwrap.
: (let Fmt (-3 14 14)
   (tab Fmt "Key" "Rand 1" "Rand 2")
   (tab Fmt "---" "------" "------")
   (for C '(A B C D E F)
      (tab Fmt C (rand) (rand)) ) )
Key        Rand 1        Rand 2
---        ------        ------
A               0    1481765933
B     -1062105905    -877267386
C      -956092119     812669700
D       553475508   -1702133896
E      1344887256   -1417066392
F      1812158119   -1999783937
-> NIL
 
- (tail 'cnt|lst 'lst) -> lst
- Returns the last cntelements oflst. Ifcntis negative, it is added to the length oflst. If
the first argument is alst,tailis a predicate
function returning that argument list if it isequalto the tail of
the second argument, andNILotherwise.(tail -2 Lst)is equivalent to(nth Lst 3). See alsooffset,head,lastandstem.
: (tail 3 '(a b c d e f))
-> (d e f)
: (tail -2 '(a b c d e f))
-> (c d e f)
: (tail 0 '(a b c d e f))
-> NIL
: (tail 10 '(a b c d e f))
-> (a b c d e f)
: (tail '(d e f) '(a b c d e f))
-> (d e f)
 
- (task 'num ['num] [sym 'any ..] [. prg]) -> lst
- A front-end to the *Runglobal. If
called with only a singlenumargument, the corresponding entry is
removed from the value of*Run. Otherwise, a new entry is created.
If an entry with that key already exists, an error is issued. For negative
numbers, a second number must be supplied. Ifsym/anyarguments are given, ajobenvironment
is built for the*Runentry. See alsoforkedandtimeout.
: (task -10000 5000 N 0 (msg (inc 'N)))            # Install task
-> (-10000 5000 (job '((N . 0)) (msg (inc 'N))))   # for every 10 seconds
: 1                                                # ... after 5 seconds
2                                                  # ... after 10 seconds
3                                                  # ... after 10 seconds
(task -10000)                                      # remove again
-> NIL
: (task (port T 4444) (eval (udp @)))              # Receive RPC via UDP
-> (3 (eval (udp @)))
# Another session (on the same machine)
: (udp "localhost" 4444 '(println *Pid))  # Send RPC message
-> (println *Pid)
 
- (telStr 'sym) -> sym
- Formats a telephone number according to the current locale. If the string head matches the local
country code, it is replaced with the national trunk prefix, otherwise+is prepended. See alsoexpTel,datStr,moneyandformat.
: (telStr "49 1234 5678-0")
-> "+49 1234 5678-0"
: (locale "DE" "de")
-> NIL
: (telStr "49 1234 5678-0")
-> "01234 5678-0"
 
- (tell ['cnt] 'sym ['any ..]) -> any
- Family IPC: Send an executable list (sym any ..)to all family
members (i.e. all children of the current process, and all other children of the
parent process, seefork) for
automatic execution. When thecntargument is given and non-zero,
it should be the PID of such a process, and the list will be sent only to that
process. When called without arguments, no message is actually sent, and the
parent process may grantsyncto the
next waiting process.tellis also used internally bycommitto notify about database changes. When
called explicitly, the size of the message is limited to the POSIX constant
PIPE_BUF. See alsokids,detachandhear.
: (call 'ps "x")                          # Show processes
  PID TTY      STAT   TIME COMMAND
  ..
 1321 pts/0    S      0:00 /usr/bin/picolisp ..  # Parent process
 1324 pts/0    S      0:01 /usr/bin/picolisp ..  # First child
 1325 pts/0    S      0:01 /usr/bin/picolisp ..  # Second child
 1326 pts/0    R      0:00 ps x
-> T
: *Pid                                    # We are the second child
-> 1325
: (tell 'println '*Pid)                   # Ask all others to print their Pid's
1324
-> *Pid
 
- (test 'any . prg)
- Executes prg, and issues anerrorif the result does notmatchtheanyargument. See alsoassert.
: (test 12 (* 3 4))
-> NIL
: (test 12 (+ 3 4))
((+ 3 4))
12 -- 'test' failed
?
 
- (text 'any1 'any ..) -> sym
- Builds a new transient symbol (string) from the string representation of
any1, by replacing all occurrences of an at-mark "@",
followed by one of the letters "1" through "9", and
"A" through "Z", with the correspondinganyargument. In this context "@A" refers to the 10th
argument. A literal at-mark in the text can be represented by two successive
at-marks. See alsopackandglue.
: (text "abc @1 def @2" 'XYZ 123)
-> "abc XYZ def 123"
: (text "a@@bc.@1" "de")
-> "a@bc.de"
 
- (throw 'sym 'any)
- Non-local jump into a previous catchenvironment with the jump labelsym(orTas a catch-all). Any pendingfinallyexpressions are executed, local
symbol bindings are restored, open files are closed and internal data structures
are reset appropriately, as the environment was at the time when the
correspondingcatchwas called. Thenanyis returned
from thatcatch. See alsoquit.
: (de foo (N)
   (println N)
   (throw 'OK) )
-> foo
: (let N 1  (catch 'OK (foo 7))  (println N))
7
1
-> 1
 
- (tick (cnt1 . cnt2) . prg) -> any
- Executes prg, then (destructively) adds the number of elapsed
user ticks to thecnt1parameter, and the number of elapsed system
ticks to thecnt2parameter. Thus,cnt1andcnt2will finally contain the total number of user and system time
ticks spent inprgand all functions called (this works also for
recursive functions). For execution profiling,tickis usually
inserted into words withprof, and removed withunprof. See alsousec.
: (de foo ()                        # Define function with empty loop
   (tick (0 . 0) (do 100000000)) )
-> foo
: (foo)                             # Execute it
-> NIL
: (pp 'foo)
(de foo NIL
   (tick (97 . 0) (do 100000000)) ) # 'tick' incremented 'cnt1' by 97
-> foo
 
- (till 'any ['flg]) -> lst|sym
- Reads from the current input channel till a character contained in
anyis found (or until end of file ifanyisNIL). IfflgisNIL, a list of
single-character transient symbols is returned. Otherwise, a single string is
returned. See alsofromandline.
: (till ":")
abc:def
-> ("a" "b" "c")
: (till ":" T)
abc:def
-> "abc"
 
- (tim$ 'tim ['flg]) -> sym
- Formats a timetim.
IfflgisNIL, the format is HH:MM, otherwise it is
HH:MM:SS. See also$timanddat$.
: (tim$ (time))
-> "10:57"
: (tim$ (time) T)
-> "10:57:56"
 
- (time ['T]) -> tim
- (time 'tim) -> (h m s)
- (time 'h 'm ['s]) -> tim | NIL
- (time '(h m [s])) -> tim | NIL
- Calculates the time of day, represented as the number of seconds since
midnight. When called without arguments, the current local time is returned.
When called with a Targument, the time of the last call todateis returned. When called with a
single numbertim, it is taken as a time value and a list with the
corresponding hour, minute and second is returned. When called with two or three
numbers (or a list of two or three numbers) for the hour, minute (and optionally
the second), the corresponding time value is returned (orNILif
they do not represent a legal time). See alsodate,stamp,usec,tim$and$tim.
: (time)                         # Now
-> 32334
: (time 32334)                   # Now
-> (8 58 54)
: (time 12 70)                   # Illegal time
-> NIL
 
- (timeout ['num])
- Sets or refreshes a timeout value in the *Runglobal, so that the current process
executesbyeafter the given period. If
called without arguments, the timeout is removed. See alsotask.
: (timeout 3600000)           # Timeout after one hour
-> (-1 3600000 (bye))
: *Run                        # Look after a few seconds
-> ((-1 3574516 (bye)))
 
- (tmp ['any ..]) -> sym
- Returns the path name to the packedanyarguments in a
process-local temporary directory. The directory name consists of the path to
".pil/tmp/" in the user's home directory, followed by the current process ID*Pid. This directory is automatically
created if necessary, and removed upon termination of the process (bye). See alsopil,*Tmpand*Bye.
: *Pid
-> 27140
: (tmp "foo" 123)
-> "/home/app/.pil/tmp/27140/foo123"
: (out (tmp "foo" 123) (println 'OK))
-> OK
: (dir (tmp))
-> ("foo123")
: (in (tmp "foo" 123) (read))
-> OK
 
- tolr/3
- Pilog predicate that succeeds if the first
argument, after folding it to a
canonical form, is either a substring or a+Snsoundex match of the result of
applying thegetalgorithm to the
following arguments. Typically used as filter predicate inselect/3database queries. See alsoisa/2,same/3,bool/3,range/3,head/3,fold/3andpart/3.
: (?
   @Nr (1 . 5)
   @Nm "Sven"
   (select (@CuSu)
      ((nr +CuSu @Nr) (nm +CuSu @Nm))
      (range @Nr @CuSu nr)
      (tolr @Nm @CuSu nm) )
   (val @Name @CuSu nm) )
 @Nr=(1 . 5) @Nm="Sven" @CuSu={2-2} @Name="Seven Oaks Ltd."
 
- (touch 'sym) -> sym
- When symis an external symbol, it is marked as "modified" so
that upon a latercommitit will be
written to the database file. An explicit call oftouchis only
necessary when the value or properties ofsymare indirectly
modified.
: (get '{2} 'lst)
-> (1 2 3 4 5)
: (set (cdr (get (touch '{2}) 'lst)) 999)    # Only read-access, need 'touch'
-> 999
: (get '{2} 'lst)                            # Modified second list element
-> (1 999 3 4 5)
 
- (trace 'sym) -> sym
- (trace 'sym 'cls) -> sym
- (trace '(sym . cls)) -> sym
- (Debug mode only) Inserts a $trace
function call at the beginning of the function or method body ofsym, so that trace information will be printed before and after
execution. Built-in functions (C-function pointer) are automatically converted
to Lisp expressions (seeexpr). See
also*Dbg,traceAllanduntrace,debugandlint.
: (trace '+)
-> +
: (+ 3 4)
 + : 3 4
 + = 7
-> 7
 
- (traceAll ['lst]) -> sym
- (Debug mode only) Traces all Lisp level functions by inserting a $function call at the beginning.lstmay contain symbols which are to be excluded from that process. In addition, all
symbols in the global variable*NoTraceare excluded. See alsotrace,untraceand*Dbg.
: (traceAll)      # Trace all Lisp level functions
-> balance
 
- (trail ['flg]) -> lst
- (64-bit version only) Returns a stack backtrace for the current point of
program execution. The list elements are either list expressions (denoting
function or method calls), or symbols followed by their corresponding values. If
flgisNIL, the symbols and their values are omitted,
and only the expressions are returned. See alsobt,upandenv.
: (de f (A B)
   (g (inc A) (dec B)) )
-> f
: (de g (X Y)
   (trail T) )
-> g
: (f 3 4)
-> ((f 3 4) A 3 B 4 (g (inc A) (dec B)) X 4 Y 3)
 
- (tree 'sym 'cls ['hook]) -> tree
- Returns a data structure specifying a database index tree. symandclsdetermine the relation, with an optionalhookobject. See alsoroot,fetch,store,count,leaf,minKey,maxKey,init,step,scan,iter,prune,zapTreeandchkTree.
: (tree 'nm '+Item)
-> (nm . +Item)
 
- (trim 'lst) -> lst
- Returns a copy of lstwith all trailing whitespace characters
orNILelements removed. See alsoclip.
: (trim (1 NIL 2 NIL NIL))
-> (1 NIL 2)
: (trim '(a b " " " "))
-> (a b)
 
- true/0
- Pilog predicate that always succeeds. See also
fail/0andrepeat/0.
:  (? (true))
-> T
 
- (try 'msg 'obj ['any ..]) -> any
- Tries to send the message msgto the objectobj,
optionally with argumentsany. Ifobjis not an
object, or if the message cannot be located inobj, in its classes
or superclasses,NILis returned. See also OO Concepts,send,method,meth,superandextra.
: (try 'msg> 123)
-> NIL
: (try 'html> 'a)
-> NIL
 
- (type 'any) -> lst
- Return the type (list of classes) of the object sym. See also
OO Concepts,isa,class,newandobject.
: (type '{1A;3})
(+Address)
: (type '+DnButton)
-> (+Tiny +Rid +JS +Able +Button)
 
- (tzo) -> cnt
- Return the time zone offset, i.e. the number of seconds east of Coordinated
Universal Time (UTC). Supported only on Linux. See also dateandtime.
: (tzo)
-> 3600