- *TStp1
- *TStp2
- Global variables holding (possibly empty) prgbodies, which
will be executed when a SIGTSTP signal (*TStp1) or a SIGCONT signal
(*TStp2) is sent to the current process. See alsoalarm,sigio,*Hup,*Sig[12]and*Winch.
: (de *TStp1 (msg 'SIGTSTP))
-> *TStp1
 
- *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/"
 
- +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 alsotasksandtimeout.
: (task -10000 5000 N 0 (tty (println (inc 'N))))  # Install task for every 10 seconds
-> (-10000 5000 (job '((N . 0)) (tty (println (inc 'N)))))
: 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)
 
- (tasks . prg)
- Runs a taskwith variable event
specification in a single*Runentry.
The task bodyprgshould return either a positive number (a file
descriptor) or a negative number (a timeout value) to be used in the next
iteration. The first value must be a timeout. A value ofNILremoves the task. Uses-2as implicit key. See alsotimeout.
(tasks  # Three iterations with varying timeout
   (let X (pop '(((-1000 . a) (-4000 . b) (-1000 . c))))
      (tty (println (cdr X)))
      (car X) ) )
(tasks
   (co 'echoes  # Coroutine
      (use S
         (loop  # Loop infinitely
            (yield -4000)  # First wait 4 seconds
            (tty (println 'OK))
            (yield  # Then wait for remote data
               (setq S
                  (pipe (exec "sh" "-c" "sleep 2; echo 7")) ) )
            (tty (println (in S (read))))
            (close S) ) ) ) )
 
- (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
 
- (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. Uses-1as
implicit key. 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={C2} @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. Can only be used with EXPRs and SUBRs. Built-in functions (SUBRs) 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
- 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
 
- (tty . prg) -> any
- Redirects the current output channel to the terminal (stderr) during the
execution of prg. The current output channel and the state ofreadline(3)will be saved and restored appropriately. See alsoout.
: (task -2000 0 (tty (println (inc (0)))))
-> (-2000 0 (tty (println (inc (0)))))
1
2
3
: (* 3 4)  # Typed while numbers are printed
 
- (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)