(c) Software Lab. Alexander Burger
This document demonstrates some aspects of the PicoLisp system in detail and example. For a general description of the PicoLisp kernel please look at the PicoLisp Reference.
This is not a Lisp tutorial, as it assumes some basic knowledge of programming, Lisp, and even PicoLisp. Please read these sections before coming back here: Introduction and The PicoLisp Machine. This tutorial concentrates on the specificities of PicoLisp, and its differences with other Lisp dialects.
If not stated otherwise, all examples assume that PicoLisp was started from a global installation (see Installation) from the shell prompt as
$ pil +
:
It loads the PicoLisp base system and the debugging environment, and waits
for you to enter input lines at the interpreter prompt (:
). You can
terminate the interpreter and return to the shell at any time, by either hitting
the Ctrl-D
key, or by executing the function (bye)
.
Please note that special handling is done during character input. This one is
incompatible with rlwrap
for example but is more powerful. It
supports vi
-style command-line editing (typos fixes and history
with ESC, h
, j
, k
and l
, or
the arrow keys if supported by the terminal).
If you prefer to use Emacs, please use the picolisp-mode bundled in the "el/" directory (that is "@lib/el" for a local installation, or some system dependent directory for a global installation).
If you feel that you absolutely have to use an IDE, rlwrap
or
another input front-end, please create an empty "~/.pil/editor" file. This
effectively disables the command line editor. Note that in this case, however,
you will not have the TAB symbol completion feature available during command
line editing.
If you are new to PicoLisp, you might want to read the following sections in the given order, as some of them assume knowledge about previous ones. Otherwise just jump anywhere you are interested in.
PicoLisp permanently reads input from the current input channel (i.e. the console in interactive mode), evaluates it, and prints the result to the current output channel. This is called a "read-eval-print-loop" (REPL).
This is the default line editor, as it needs less system resources and works also on dumb terminals. It is similar to - though simpler than - the 'vi' edit modes of the 'korn' and 'bash' shells. For an analog 'emacs' style editor, please see below.
It is very helpful - though not absolutely necessary - when you know how to
use the vi
text editor.
To alleviate the task of manual line input, a command line editor is provided
which is similar to (though much simpler than) the readline
feature
of the bash
shell. Only a subset of the vi
mode is
supported, which is restricted to single-key commands (the "real"
vi
supports multi-key commands and the modification of most
commands with count prefixes). It is loaded at startup in debug mode, you find
its source in "lib/led.l".
You can enter lines in the normal way, correcting mistypes with the BACKSPACE key, and terminating them with the ENTER key. This is the Insert Mode.
If you hit ESC, you get into Command Mode. Now you can navigate
horizontally in the current input line, or vertically in the history of
previously entered lines, with key commands borrowed from the vi
editor (only h
, j
, k
and l
,
or the arrow keys if supported by the terminal). Note, however, that there is
always only a single line visible.
Let's say you did some calculation
: (* (+ 2 3) (- 7 2))
-> 25
:
If you want to repeat a modified version of this command, using
8
instead of 7
, you don't have to re-type the
whole command, but type
k
to get one line "up"
f
and 7
to "find" the character 7
r
and 8
to "replace" with 8
Then you hit ENTER to execute the modified line. Instead of jumping to the
7
with the "find" command, you may also type l
(move
"right") repeatedly till you reach the correct position.
The key commands in the Command Mode are listed below. Some commands change the mode back to Insert Mode as indicated in parentheses. Deleting or changing a "word" take either the current atom (number or symbol), or a whole expression when the cursor is at a left parenthesis.
k
- Go up one line
j
- Go down one line
l
- Go right one character
h
- Go left one character
w
- Go right one word
e
- Go to next word end
b
- Go back (left) one word
0
- Go to the beginning of the line
$
- Go to the end of the line
i
- Enter Insert Mode at the cursor position
a
- Append (Insert Mode) after the cursor position
A
- Append (Insert Mode) at the end of the line
I
- Insert (Insert Mode) at the beginning of the line
x
- Delete the character at the cursor position
X
- Delete the character left of the cursor position
r
- Replace the character at the cursor position with the next key
s
- Substitute the character at the cursor position (Insert Mode)
S
- Substitute the whole line (Insert Mode)
d
- Delete the word at the cursor position (Insert Mode)
D
- Delete the rest of the line
c
- Change the word at the cursor position (Insert Mode)
C
- Change the rest of the line (Insert Mode)
f
- Find next key in the rest of the current line
p
- Paste data deleted with x
, X
, d
or D
after the cursor position
P
- Paste data deleted with x
, X
, d
or D
before the cursor position
/
- Accept an input pattern and search the history for it
n
- Search for next occurrence of pattern (as entered with /
)
N
- Search for previous occurrence of pattern
%
- Go to matching parenthesis
~
- Convert character to opposite (lower or upper) case and move right
u
- Undo the last change (one level only)
U
- Undo all changes of the current line
g
- Display current contents of cut buffer (not in vi
)
Notes:
d
command corresponds to the dw
command of the
vi
editor, and c
corresponds to cw
.
@
" characters as wildcards.
The following two key-combinations work both in Insert and Command Mode:
Ctrl-D
will immediately terminate the current process.
Ctrl-X
discards all input, abandons further processing, and
returns to the interpreter's top level (equivalent to invoking quit
). This is also useful when the program
stopped at a breakpoint (see single-stepping Debugging), or
after program execution was interrupted with Ctrl-C
.
Besides these two keys, in Insert Mode only the following keys have a special meaning:
Ctrl-H
) and DEL erase the character to the left
Ctrl-V
inserts the next key literally
Ctrl-E
lets you edit
the history
Ctrl-F
saves the history
You can switch the command line editor to an 'emacs' style, if you call the
function (em)
(i.e. without arguments). A single call is enough.
Alternatively, you could invoke PicoLisp at least once with the -em
command line option
$ pil -em +
:
The style will be remembered in a file "~/.pil/editor", and used in all subsequent PicoLisp sessions.
To switch back to 'vi' style, call (vi)
, use the
-vi
command line option, or simply remove "~/.pil/editor".
Please take some time to experiment and to get used to command line editing. It will make life much easier in the future :-)
PicoLisp provides some functionality for inspecting pieces of data and code within the running system.
print
,
size
...
But you will appreciate some more powerful tools like:
match
, a predicate which
compares S-expressions with bindable wildcards when matching,The most commonly used tool is probably the show
function. It takes a symbolic argument,
and shows the symbol's name (if any), followed by its value, and then the
contents of the property list on the following lines (assignment of such things
to a symbol can be done with set
,
setq
, and put
).
: (setq A '(This is the value)) # Set the value of 'A'
-> (This is the value)
: (put 'A 'key1 'val1) # Store property 'key1'
-> val1
: (put 'A 'key2 'val2) # and 'key2'
-> val2
: (show 'A) # Now 'show' the symbol 'A'
A (This is the value)
key2 val2
key1 val1
-> A
show
accepts an arbitrary number of arguments which are
processed according to the rules of get
, resulting in a symbol which is showed then.
: (put 'B 'a 'A) # Put 'A' under the 'a'-property of 'B'
-> A
: (setq Lst '(A B C)) # Create a list with 'B' as second argument
-> (A B C)
: (show Lst 2 'a) # Show the property 'a of the 2nd element of 'Lst'
A (This is the value) # (which is 'A' again)
key2 val2
key1 val1
-> A
Similar to show
is edit
. It takes an arbitrary number of symbolic
arguments, writes them to a temporary file in a format similar to
show
, and starts the vim
editor with that file.
: (edit 'A 'B)
The vim
window will look like
A (This is the value)
key1 val1
key2 val2
(=======)
B NIL
a A # (This is the value)
(=======)
Now you can modify values or properties. You should not touch the
parenthesized hyphens, as they serve as delimiters. If you position the cursor
on the first character of a symbol name and type 'K
' ("Keyword
lookup"), the editor will be restarted with that symbol added to the editor
window. 'Q
' (for "Quit") will bring you back to the previous view.
And, pressing 'Q' at the first (or, top-level) view will return you to the REPL with any changes you made in your 'edit' session communicated back to the REPL session.
edit
is also very useful to browse in a database. You can follow
the links between objects with 'K
', and even - e.g. for low-level
repairs - modify the data (but only if you are really sure about what you are
doing, and don't forget to commit
when you are done).
The pretty-print function pp
takes a symbol that has a function defined (or two symbols that specify message
and class for a method definition), and displays that definition in a formatted
and indented way.
: (pp 'pretty)
(de pretty (X N)
(setq N (abs (space (or N 0))))
(while (and (pair X) (== 'quote (car X)))
(prin "'")
(pop 'X) )
(cond
...
(T (prtty0 X N)) ) )
-> pretty
The style is the same as we use in source files:
size
is greater than 12), pretty-print the CAR
on the current line, and each element of the CDR recursively on its own line.
more
is a simple tool that displays
the elements of a list one by one. It stops after each element and waits for
input. If you just hit ENTER, more
continues with the next element,
otherwise (usually I type a dot (.
) followed by ENTER) it
terminates.
: (more (1 2 3 4 5 6))
1 # Hit ENTER
2. # Hit '.' and ENTER
-> T # stopped
Optionally more
takes a function as a second argument and
applies that function to each element (instead of the default print
). Here, often show
or
pp
(see below) is used.
: (more '(A B)) # Step through 'A' and 'B'
A
B
-> NIL
: (more '(A B) show) # Step through 'A' and 'B' with 'show'
A (This is the value) # showing 'A'
key2 val2
key1 val1
# Hit ENTER
B NIL # showing 'B'
a A
-> NIL
The what
function returns a list of
all internal symbols in the system which match a given pattern (with
'@
' wildcard characters).
: (what "prin@")
-> (prin print prinl print> printsp println)
The function who
returns "who
contains that", i.e. a list of symbols that contain a given argument
somewhere in their value or property list.
: (who 'print)
-> (query pretty pp msg more "edit" view show (print> . +Date) rules select
(print> . +relation))
A dotted pair indicates either a method definition or a property entry. So
(print> . +relation)
denotes the print>
method of
the +relation
class.
who
can be conveniently combined with more
and
pp
:
: (more (who 'print) pp)
(de query ("Q" "Dbg") # Pretty-print these functions one by one
(use "R"
(loop
(NIL (prove "Q" "Dbg"))
(T (=T (setq "R" @)) T)
(for X "R"
(space)
(print (car X))
(print '=)
(print (cdr X))
(flush) )
(T (line)) ) ) )
(de pretty (X N)
...
The argument to who
may also be a pattern list (see match
):
: (who '(print @ (val @)))
-> (show)
: (more (who '(% @ 7)) pp)
(de day (Dat Lst)
(when Dat
(get
(or Lst *DayFmt)
(inc (% (inc Dat) 7)) ) ) )
(de _week (Dat)
(/ (- Dat (% (inc Dat) 7)) 7) )
The function can
returns a list
which indicates which classes can accept a given message. Again, this
list is suitable for iteration with pp
:
: (can 'del>) # Which classes accept 'del>' ?
-> ((del> . +List) (del> . +Entity) (del> . +relation))
: (more (can 'del>) pp) # Inspect the methods with 'pp'
(dm (del> . +List) (Obj Old Val)
(and ((<> Old Val) (delete Val Old)) )
(dm (del> . +Entity) (Var Val)
(when
(and
Val
(has> (meta This Var) Val (get This Var)) )
(let Old (get This Var)
(rel>
(meta This Var)
This
Old
(put This Var (del> (meta This Var) This Old @)) )
(when (asoq Var (meta This 'Aux))
(relAux This Var Old (cdr @)) )
(upd> This Var Old) ) ) )
(dm (del> . +relation) (Obj Old Val)
(and ((<> Old Val) Val) )
dep
shows the dependencies in a
class hierarchy. That is, for a given class it displays the tree of its
(super)class(es) above it, and the tree of its subclasses below it.
To view the complete hierarchy of input fields, we start with the root class
+relation
:
: (dep '+relation)
+relation
+Bag
+Any
+Blob
+Link
+Joint
+Bool
+Symbol
+String
+Number
+Time
+Date
-> +relation
If we are interested in +Link
:
: (dep '+Link)
+relation
+Link
+Joint
-> +Link
This says that +Link
is a subclass of +relation
, and has a single subclass
(+Joint
).
Most of the time during programming is spent defining functions (or methods).
In the following we will concentrate on functions, but most will be true for
methods as well except for using dm
instead of de
.
The notorious "Hello world" function must be defined:
: (de hello ()
(prinl "Hello world") )
-> hello
The ()
in the first line indicates a function without arguments.
The body of the function is in the second line, consisting of a single
statement. The last line is the return value of de
, which here is
the defined symbol. From now on we will omit the return values of examples when
they are unimportant.
Now you can call this function this way:
: (hello)
Hello world
A function with an argument might be defined this way:
: (de hello (X)
(prinl "Hello " X) )
# hello redefined
-> hello
PicoLisp informs you that you have just redefined the function. This might be a useful warning in case you forgot that a bound symbol with that name already existed.
: (hello "world")
Hello world
: (hello "Alex")
Hello Alex
Normally, PicoLisp evaluates the arguments before it passes them to a function:
: (hello (+ 1 2 3))
Hello 6
: (setq A 1 B 2) # Set 'A' to 1 and 'B' to 2
-> 2
: (de foo (X Y) # 'foo' returns the list of its arguments
(list X Y) )
-> foo
: (foo A B) # Now call 'foo' with 'A' and 'B'
-> (1 2) # -> We get a list of 1 and 2, the values of 'A' and 'B'
In some cases you don't want that. For some functions (setq
for example) it is better if the function
gets all arguments unevaluated, and can decide for itself what to do with them.
For such cases you do not define the function with a list of parameters, but give it a single atomic parameter instead. PicoLisp will then bind all (unevaluated) arguments as a list to that parameter.
: (de foo X
(list (car X) (cadr X)) ) # 'foo' lists the first two arguments
: (foo A B) # Now call it again
-> (A B) # -> We don't get '(1 2)', but '(A B)'
: (de foo X
(list (car X) (eval (cadr X))) ) # Now evaluate only the second argument
: (foo A B)
-> (A 2) # -> We get '(A 2)'
As a logical consequence, you can combine these principles. To define a function with 2 evaluated and an arbitrary number of unevaluated arguments:
: (de foo (X Y . Z) # Evaluate only the first two args
(list X Y Z) )
: (foo A B C D E)
-> (1 2 (C D E)) # -> Get the value of 'A' and 'B' and the remaining list
More common, in fact, is the case where you want to pass an arbitrary number
of evaluated arguments to a function. For that, PicoLisp recognizes the
symbol @
as a single atomic parameter and remembers all evaluated
arguments in an internal frame. This frame can then be accessed sequentially
with the args
, next
, arg
and rest
functions.
: (de foo @
(list (next) (next)) ) # Get the first two arguments
: (foo A B)
-> (1 2)
Again, this can be combined:
: (de foo (X Y . @)
(list X Y (next) (next)) ) # 'X' and 'Y' are fixed arguments
: (foo A B (+ 3 4) (* 3 4))
-> (1 2 7 12) # All arguments are evaluated
These examples are not very useful, because the advantage of a variable number of arguments is not used. A function that prints all its evaluated numeric arguments, each on a line followed by its squared value:
: (de foo @
(while (args) # Check if there are some args left
(println (next) (* (arg) (arg))) ) ) # Call the last arg (next) returned
: (foo (+ 2 3) (- 7 1) 1234 (* 9 9))
5 25
6 36
1234 1522756
81 6561
-> 6561
This next example shows the behaviour of args
and
rest
:
: (de foo @
(while (args)
(next)
(println (arg) (args) (rest)) ) )
: (foo 1 2 3)
1 T (2 3)
2 T (3)
3 NIL NIL
Finally, it is possible to pass all these evaluated arguments to another
function, using pass
:
: (de foo @
(pass println 9 8 7) # First print all arguments preceded by 9, 8, 7
(pass + 9 8 7) ) # Then add all these values
: (foo (+ 2 3) (- 7 1) 1234 (* 9 9))
9 8 7 5 6 1234 81 # Printing ...
-> 1350 # Return the result
quote
will do what you want (see
also this FAQ entry).
: ((quote (X) (* X X)) 9)
-> 81
: (setq f '((X) (* X X))) # This is equivalent to (de f (X) (* X X))
-> ((X) (* X X))
: f
-> ((X) (* X X))
: (f 3)
-> 9
There are two major ways to debug functions (and methods) at runtime: Tracing and single-stepping.
In this section we will use the REPL to explore the debugging facilities, but in the Scripting section, you will learn how to launch PicoLisp scripts with some selected functions debugged:
$ pil app/file1.l -"trace 'foo" -main -"debug 'bar" app/file2.l +
Tracing means letting functions of interest print their name and arguments when they are entered, and their name again and the return value when they are exited.
For demonstration, let's define the unavoidable factorial function (or just
load
the file<EMAIL_ADDRESS>"):
(de fact (N)
(if (=0 N)
1
(* N (fact (dec N))) ) )
With trace
we can put it in trace
mode:
: (trace 'fact)
-> fact
Calling fact
now will display its execution trace.
: (fact 3)
fact : 3
fact : 2
fact : 1
fact : 0
fact = 1
fact = 1
fact = 2
fact = 6
-> 6
As can be seen here, each level of function call will indent by an additional
space. Upon function entry, the name is separated from the arguments with a
colon (:
), and upon function exit with an equals sign
(=
) from the return value.
trace
works by modifying the function body, so generally it
works only for functions defined as lists (lambda expressions, see Evaluation). Tracing a built-in function (SUBR) is
possible, however, when it is a function that evaluates all its arguments.
So let's trace the functions =0
and
*
:
: (trace '=0)
-> =0
: (trace '*)
-> *
If we call fact
again, we see the additional output:
: (fact 3)
fact : 3
=0 : 3
=0 = NIL
fact : 2
=0 : 2
=0 = NIL
fact : 1
=0 : 1
=0 = NIL
fact : 0
=0 : 0
=0 = 0
fact = 1
* : 1 1
* = 1
fact = 1
* : 2 1
* = 2
fact = 2
* : 3 2
* = 6
fact = 6
-> 6
To reset a function to its untraced state, call untrace
:
: (untrace 'fact)
-> fact
: (untrace '=0)
-> =0
: (untrace '*)
-> *
or simply use mapc
:
: (mapc untrace '(fact =0 *))
-> *
Single-stepping means to execute a function step by step, giving the
programmer an opportunity to look more closely at what is happening. The
function debug
inserts a breakpoint
into each top-level expression of a function. When the function is called, it
stops at each breakpoint, displays the expression it is about to execute next
(this expression is also stored into the global variable ^
) and enters a read-eval-loop. The programmer can
then
(d)
to recursively debug the
next expression (looping through subexpressions of this expression)
(e)
to evaluate the next
expression, to see what will happen without actually advancing on
Thus, in the simplest case, single-stepping consists of just hitting ENTER repeatedly to step through the function.
To try it out, let's look at the stamp
system function. You may need to have a
look at
=T
(T test),date
and time
(grab system date and time)
default
(conditional
assignments)
pack
(kind of concatenation), and
dat$
and tim$
(date and time formats)
: (pp 'stamp)
(de stamp (Dat Tim)
(and (=T Dat) (setq Dat (date T)))
(default Dat (date) Tim (time T))
(pack (dat$ Dat "-") " " (tim$ Tim T)) )
-> stamp
: (debug 'stamp) # Debug it
-> T
: (stamp) # Call it again
(and (=T Dat) (setq Dat (date T))) # stopped at first expression
! # ENTER
(default Dat (date) Tim (time T)) # second expression
! # ENTER
(pack (dat$ Dat "-") " " (tim$ ... # third expression
! Tim # inspect 'Tim' variable
-> 41908
! (time Tim) # convert it
-> (11 38 28)
! # ENTER
-> "2004-10-29 11:38:28" # done, as there are only 3 expressions
Now we execute it again, but this time we want to look at what's happening inside the second expression.
: (stamp) # Call it again
(and (=T Dat) (setq Dat (date T)))
! # ENTER
(default Dat (date) Tim (time T))
! # ENTER
(pack (dat$ Dat "-") " " (tim$ ... # here we want to look closer
! (d) # debug this expression
-> T
! # ENTER
(dat$ Dat "-") # stopped at first subexpression
! (e) # evaluate it
-> "2004-10-29"
! # ENTER
(tim$ Tim T) # stopped at second subexpression
! (e) # evaluate it
-> "11:40:44"
! # ENTER
-> "2004-10-29 11:40:44" # done
The breakpoints still remain in the function body. We can see them when we pretty-print it:
: (pp 'stamp)
(de stamp (Dat Tim)
(! and (=T Dat) (setq Dat (date T)))
(! default Dat (date) Tim (time T))
(! pack
(! dat$ Dat "-")
" "
(! tim$ Tim T) ) )
-> stamp
To reset the function to its normal state, call unbug
:
: (unbug 'stamp)
Often, you will not want to single-step a whole function. Just use
edit
(see above) to insert a single breakpoint (the exclamation
mark followed by a space) as CAR of an expression, and run your program.
Execution will then stop there as described above; you can inspect the
environment and continue execution with ENTER when you are done.
Input and output in PicoLisp is functional, in the sense that there are not variables assigned to file descriptors, which need then to be passed to I/O functions for reading, writing and closing. Instead, these functions operate on implicit input and output channels, which are created and maintained as dynamic environments.
Standard input and standard output are the default channels. Try reading a single expression:
: (read)
(a b c) # Console input
-> (a b c)
To read from a file, we redirect the input with in
. Note that comments and whitespace are
automatically skipped by read
:
: (in<EMAIL_ADDRESS>(read))
-> (de fact (N) (if (=0 N) 1 (* N (fact (dec N)))))
The skip
function can also be used
directly. To get the first non-white character in the file with char
:
: (in<EMAIL_ADDRESS>(skip "#") (char))
-> "("
from
searches through the input
stream for given patterns. Typically, this is not done with Lisp source files
(there are better ways), but for a simple example let's extract all items
immediately following fact
in the file,
: (in<EMAIL_ADDRESS>(while (from "fact ") (println (read))))
(N)
(dec N)
or the word following "(de " with till
:
: (in<EMAIL_ADDRESS>(from "(de ") (till " " T))
-> "fact"
To read the contents of a whole file (or the rest of it starting from the current position):
: (in "f.l" (till NIL T))
-> "... file contents ..."
With line
, a line of characters is
read, either into a single transient symbol
(the type used by PicoLisp for strings),
: (in<EMAIL_ADDRESS>(line T))
-> "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://..."
or into a list of symbols (characters):
: (in<EMAIL_ADDRESS>(line))
-> ("<" "!" "D" "O" "C" "T" "Y" "P" "E" " " "H" "T" "M" "L" ...
line
is typically used to read tabular data from a file.
Additional arguments can split the line into fixed-width fields, as described in
the reference manual
. If, however, the
data are of variable width, delimited by some special character, the split
function can be used to extract the
fields. A typical way to import the contents of such a file is:
(load<EMAIL_ADDRESS>(in '("bin/utf2" "importFile.txt") # Pipe: Convert to UTF-8
(until (eof) # Process whole file
(let L (split (line) "^I") # TAB-delimited data
... use 'getStr', 'getNum' etc ... # process them
Some more examples with echo
:
(in "a" # Copy the first 40 Bytes
(out "b" # from file "a" to file "b"
(echo 40) ) )
(in<EMAIL_ADDRESS># Show the HTTP-header
(line)
(echo "<body>") )
(out "file.mac" # Convert to Macintosh
(in "file.txt" # from Unix or DOS format:
(while (char)
(prin
(case @
("^M" NIL) # ignore CR
("^J" "^M") # convert LF to CR
(T @) ) ) ) ) ) # otherwise no change
(out "c" # Merge the contents of "a"
(in "b" # and "b" into "c"
(in "a"
(while (read) # Read an item from "a",
(println @ (in -1 (read))) ) ) ) ) # print it with an item from "b"
There are two possibilities to get the PicoLisp interpreter into doing useful work: via command line arguments, or as a stand-alone script.
The command line can specify either files for execution, or arbitrary Lisp
expressions for direct evaluation (see Invocation):
if an argument starts with a hyphen, it is evaluated, otherwise it is load
ed as a file. A typical invocation might
look like:
$ pil app/file1.l -main app/file2.l +
It loads the debugging environment, an application source file, calls the main function, and then loads another application source. In a typical development and debugging session, this line is often modified using the shell's history mechanisms, e.g. by inserting debugging statements:
$ pil app/file1.l -"trace 'foo" -main -"debug 'bar" app/file2.l +
Another convenience during debugging and testing is to put things into the command line (shell history) which would otherwise have to be done each time in the application's user interface:
$ pil app/file1.l -main app/file2.l -go -'login "name" "password"' +
The final production release of an application usually includes a shell script, which initializes the environment, does some bookkeeping and cleanup, and calls the application with a proper command line. It is no problem if the command line is long and complicated.
For small utility programs, however, this is overkill. Enter full PicoLisp scripts.
#!
", the operating
system kernel will pass this file to an interpreter program whose pathname is
given in the first line (optionally followed by a single argument). This is fast
and efficient, because the overhead of a subshell is avoided.
Let's assume you installed PicoLisp in the directory "/home/foo/picolisp/", and put links to the executable and the installation directory as:
$ ln -s /home/foo/picolisp /usr/lib/picolisp
$ ln -s /usr/lib/picolisp/bin/picolisp /usr/bin/picolisp
Then a simple hello-world script might look like:
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
(prinl "Hello world!")
(bye)
If you write this into a text file, and use chmod
to set it to
"executable", it can be executed like any other command. Note that (because
#
is the comment character in PicoLisp) the first line will not be
interpreted, and you can still use that file as a normal command line argument
to PicoLisp (useful during debugging).
The fact that a hyphen causes evaluation of command line arguments can be
used to simulate something like command line options. The following script
defines two functions a
and f
, and then calls
(load T)
to process the rest of the
command line (which otherwise would be ignored because of the (bye)
statement):
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
(de a ()
(println '-a '-> (opt)) )
(de f ()
(println '-f '-> (opt)) )
(load T)
(bye)
(opt
retrieves the next command line
option)
Calling this script (let's say we named it "testOpts") gives:
$ ./testOpts -f abc
-f -> "abc"
$ ./testOpts -a xxx -f yyy
-a -> "xxx"
-f -> "yyy"
We have to be aware of the fact, however, that the aggregation of arguments like
$ ./testOpts -axxx -fyyy
or
$ ./testOpts -af yyy
cannot be achieved with this simple and general mechanism of command line processing.
Utilities are typically used outside the context of the PicoLisp environment. All examples above assumed that the current working directory is the PicoLisp installation directory, which is usually all right for applications developed in that environment. Command line file arguments like "app/file1.l" will be properly found.
To allow utilities to run in arbitrary places on the host file system, the
concept of home directory substitution was introduced. The interpreter
remembers internally at start-up the pathname of its first argument (usually
"lib.l"), and substitutes any leading "@
" character in subsequent
file names with that pathname. Thus, to run the above example in some other
place, simply write:
$ /home/foo/picolisp/pil @app/file1.l -main @app/file2.l +
that is, supply a full path name to the initial command (here 'pil'), or put
it into your PATH
variable, and prefix each file which has to be
loaded from the PicoLisp home directory with a @
character.
"Normal" files (not prefixed by @
) will be opened or created
relative to the current working directory as usual.
Stand-alone scripts will often want to load additional modules from the PicoLisp environment, beyond the "lib.l" we provided in the first line of the hello-world script. Typically, at least a call to
(load<EMAIL_ADDRESS>(note the home directory substitution) will be included near the beginning of the script.
As a more complete example, here is a script which extracts the date, name and size of the latest official PicoLisp release version from the download web site, and prints it to standard output:
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
(load<EMAIL_ADDRESS><EMAIL_ADDRESS>(use (@Date @Name @Size)
(when
(match
'(@Date ~(chop " - <a href=\"") @Name "\"" ">"
@Name ~(chop "</a> (") @Size )
(client "software-lab.de" 80 "down.html"
(from "Release Archive")
(from "<li>")
(till ",") ) )
(prinl @Name)
(prinl @Date " -- " @Size) ) )
(bye)
We recommend that you have a terminal window open, and try the examples by
yourself. You may either type them in, directly to the PicoLisp interpreter, or
edit a separate source file (e.g<EMAIL_ADDRESS>) in a second
terminal window and load it into PicoLisp with
: (load<EMAIL_ADDRESS>each time you have modified and saved it.
Once a function is loaded from a source file, you can call 'vim' directly on that function with
: (vi 'fact)
The function 'vi' opens the appropriate source file, and jumps to the right line where 'fact' is defined. When you modify it, you can simply call 'ld' to (re)load that source file
: (ld)
The PicoLisp object model is very simple, yet flexible and powerful. Objects as well as classes are both implemented as symbols. In fact, there is no formal difference between objects and classes; classes are more a conceptual design consideration in the head of the programmer than a physical reality.
Having said this, we declare that normally:
So the main difference between classes and objects is that the former ones
usually are internal symbols. By convention, their names start with a
'+
'. Sometimes it makes sense, however, to create named objects (as
global singletons, for example), or even anonymous classes.
Both classes and objects have a list in their value, consisting of method definitions (often empty for objects) and (super)class(es). And both classes and objects have local data in their property lists (often empty for classes). This implies, that any given object (as an instance of a class) may have private (object-local) methods defined.
It is rather difficult to contrive a simple OOP example. We constructed a
hierarchy of geometric shapes, with a base class +Shape
and two
subclasses +Rectangle
and +Circle
.
The source code is included as<EMAIL_ADDRESS>" in the PicoLisp distribution, so you
don't have to type it in. Just load
the file, or start it from the shell as:
$ pil @doc/shape.l +
Let's look at it piece by piece. Here's the base class:
(class +Shape)
# x y
(dm T (X Y)
(=: x X)
(=: y Y) )
(dm move> (DX DY)
(inc (:: x) DX)
(inc (:: y) DY) )
The first line '(class +Shape)
' defines the symbol
+Shape
as a class without superclasses. The following method
definitions will go to that class.
The comment '# x y
' in the second line is just a convention, to
indicate what instance variables (properties) that class uses. As PicoLisp is a
dynamic language, a class can be extended at runtime with any number of
properties, and there is nothing like a fixed object size or structure. This
comment is a hint of what the programmer thinks to be essential and typical for
that class. In the case of +Shape
, x
and
y
are the coordinates of the shape's origin.
Then we have two method definitions, using the keyword dm
for "define method". The first method is
special, in that its name is T
. Each time a new object is created,
and a method with that name is found in its class hierarchy, that method will be
executed. Though this looks like a "constructor" in other programming languages,
it should probably better be called "initializer". The T
method of
+Shape
takes two arguments X
and Y
, and
stores them in the object's property list.
The second method move>
changes the object's origin by adding
the offset values DX
and DY
to the object's origin.
Now to the first derived class:
(class +Rectangle +Shape)
# dx dy
(dm T (X Y DX DY)
(super X Y)
(=: dx DX)
(=: dy DY) )
(dm area> ()
(* (: dx) (: dy)) )
(dm perimeter> ()
(* 2 (+ (: dx) (: dy))) )
(dm draw> ()
(drawRect (: x) (: y) (: dx) (: dy)) )
+Rectangle
is defined as a subclass of +Shape
.
The comment '# dx dy
' indicates that +Rectangle
has a
width and a height in addition to the origin coordinates inherited from
+Shape
.
The T
method passes the origin coordinates X
and
Y
to the T
method of the superclass
(+Shape
), then stores the width and height parameters into
dx
and dy
.
Next we define the methods area>
and
perimeter>
which do some obvious calculations, and a method
draw>
which is supposed to draw the shape on the screen by
calling some hypothetical function drawRect
.
Finally, we define a +Circle
class in an analog way, postulating
the hypothetical function drawCircle
:
(class +Circle +Shape)
# r
(dm T (X Y R)
(super X Y)
(=: r R) )
(dm area> ()
(*/ (: r) (: r) 31415927 10000000) )
(dm perimeter> ()
(*/ 2 (: r) 31415927 10000000) )
(dm draw> ()
(drawCircle (: x) (: y) (: r)) )
Now we can experiment with geometrical shapes. We create a rectangle at point
(0,0) with a width of 30 and a height of 20, and keep it in the variable
R
:
: (setq R (new '(+Rectangle) 0 0 30 20)) # New rectangle
-> $134432824 # returned anonymous symbol
: (show R)
$134432824 (+Rectangle) # Show the rectangle
dy 20
dx 30
y 0
x 0
We see that the symbol $134432824
has a list of classes
'(+Rectangle)
' in its value, and the coordinates, width and height
in its property list.
Sending messages to that object
: (area> R) # Calculate area
-> 600
: (perimeter> R) # and perimeter
-> 100
will return the values for area and perimeter, respectively.
Then we move the object's origin:
: (move> R 10 5) # Move 10 right and 5 down
-> 5
: (show R)
$134432824 (+Rectangle)
y 5 # Origin changed (0,0) -> (10,5)
x 10
dy 20
dx 30
Though a method move>
wasn't defined for the
+Rectangle
class, it is inherited from the +Shape
superclass.
Similarly, we create and use a circle object:
: (setq C (new '(+Circle) 10 10 30)) # New circle
-> $134432607 # returned anonymous symbol
: (show C)
$134432607 (+Circle) # Show the circle
r 30
y 10
x 10
-> $134432607
: (area> C) # Calculate area
-> 2827
: (perimeter> C) # and perimeter
-> 188
: (move> C 10 5) # Move 10 right and 5 down
-> 15
: (show C)
$134432607 (+Circle) # Origin changed (10,10) -> (20,15)
y 15
x 20
r 30
It is also easy to send messages to objects in a list:
: (mapcar 'area> (list R C)) # Get list of areas
-> (600 2827)
: (mapc
'((Shape) (move> Shape 10 10)) # Move all 10 right and down
(list R C) )
-> 25
: (show R)
$134431493 (+Rectangle)
y 15
x 20
dy 20
dx 30
-> $134431493
: (show C)
$134431523 (+Circle)
y 25
x 30
r 30
Assume that we want to extend our shape system. From time to time, we need
shapes that behave exactly like the ones above, but are tied to a fixed
position. That is, they do not change their position even if they receive a
move>
message.
One solution would be to modify the move>
method in the
+Shape
class to a no-operation. But this would require to duplicate
the whole shape hierarchy (e.g. by defining +FixedShape
,
+FixedRectangle
and +FixedCircle
classes).
The PicoLisp Way is the use of Prefix Classes through multiple inheritance. It uses the fact that searching for method definitions is a depth-first, left-to-right search of the class tree. We define a prefix class:
: (class +Fixed)
(dm move> (DX DY)) # A do-nothing method
We can now create a fixed rectangle, and try to move it:
: (setq R (new '(+Fixed +Rectangle) 0 0 30 20)) # '+Fixed' prefix class
-> $134432881
: (move> R 10 5) # Send 'move>' message
-> NIL
: (show R)
$134432881 (+Fixed +Rectangle)
dy 20
dx 30
y 0 # Did not move!
x 0
We see, prefix classes can surgically change the inheritance tree for selected objects or classes.
Alternatively, if fixed rectangles are needed often, it might make sense to
define a new class +FixRect
:
: (class +FixRect +Fixed +Rectangle)
-> +FixRect
and then use it directly:
: (setq R (new '(+FixRect) 0 0 30 20))
-> $13455710
PicoLisp has persistent objects built-in as a first class data type. With "first class" we mean not just the ability of being passed around, or returned from functions (that's a matter of course), but that they are a primary data type with their own interpreter tag bits. They are, in fact, a special type of symbolic atoms (called "External Symbols"), that happen to be read from pool file(s) when accessed, and written back automatically when modified.
In all other aspects they are normal symbols. They have a value, a property list and a name.
The name cannot be directly controlled by the programmer, as it is assigned
when the symbol is created. It is an encoded index of the symbol's location in
its database file. In its visual representation (output by the print
functions and input by the read
functions) it is surrounded by braces.
To make use of external symbols, you need to open a database first:
: (pool "test.db")
If a file with that name did not exist, it got created now. Also created at
the same moment was {1}
, the very first symbol in the file. This
symbol is of great importance, and is handled especially by PicoLisp. Therefore
a global constant *DB
exists, which
points to that symbol {1}
, which should be used exclusively to
access the symbol {1}
, and which should never be modified by the
programmer.
: *DB # The value of '*DB'
-> {1} # is '{1}'
: (show *DB)
{1} NIL # Value of '{1}' is NIL, property list empty
Now let's put something into the value and property list of {1}
.
: (set *DB "Hello world") # Set value of '{1}' to a transient symbol (string)
-> "Hello world"
: (put *DB 'a 1) # Property 'a' to 1
-> 1
: (put *DB 'b 2) # Property 'b' to 2
-> 2
: (show *DB) # Now show the symbol '{1}'
{1} "Hello world"
b 2
a 1
Note that instead of '(set *DB "Hello world")
', we might
also have written '(setq {1} "Hello world")
', and instead of
'(put *DB 'a 1)
' we might have written '(put '{1} 'a
1)
'. This would have the same effect, but as a rule external symbols
should never be be accessed literally in application programs, because the
garbage collector might not be able to free these symbols and all symbols
connected to them (and that might well be the whole database). It is all right,
however, to access external symbols literally during interactive debugging.
Now we can create our first own external symbol. This can be done with
new
when a T
argument is
supplied:
: (new T)
-> {2} # Got a new symbol
We store it in the database root {1}
:
: (put *DB 'newSym '{2}) # Literal '{2}' (ok during debugging)
-> {2}
: (show *DB)
{1} "Hello world"
newSym {2} # '{2}' is now stored in '{1}'
b 2
a 1
Put some property value into '{2}'
: (put *DB 'newSym 'x 777) # Put 777 as 'x'-property of '{2}'
-> 777
: (show *DB 'newSym) # Show '{2}' (indirectly)
{2} NIL
x 777
-> {2}
: (show '{2}) # Show '{2}' (directly)
{2} NIL
x 777
All modifications to - and creations of - external symbols done so far are
not written to the database yet. We could call rollback
(or simply exit PicoLisp) to undo
all the changes. But as we want to keep them:
: (commit) # Commit all changes
-> T
: (bye) # Exit picolisp
$ # back to the shell
So, the next time when ..
$ pil + # .. we start PicoLisp
: (pool "test.db") # and open the database file,
-> T
: (show *DB) # our two symbols are there again
{1} "Hello world"
newSym {2}
b 2
a 1
-> {1}
: (show *DB 'newSym)
{2} NIL
x 777
-> {2}
To a database, there is more than just persistence. PicoLisp includes an entity/relation class framework (see also Database) which allows a close mapping of the application data structure to the database.
We provided a simple yet complete database and GUI demo application in
@doc/family.tgz
and @doc/family64.tgz
. Please unpack the first one if
you use a 32-bit system, and the second one on a 64-bit system. Both contain the
sources in @doc/family.l
, and an initial
database in the "family/" subdirectory.
To use it, please unpack it first in your current working directory, then start it up in the following way:
$ pil family.l -main +
:
This loads the source file, initializes the database by calling the
main
function, and prompts for user input.
The data model is small and simple. We define a class +Person
and two subclasses +Man
and +Woman
.
(class +Person +Entity)
+Person
is a subclass of the +Entity
system class. Usually all objects in
a database are of a direct or indirect subclass of +Entity
. We can then define the relations to
other data with the rel
function.
(rel nm (+Need +Sn +Idx +String)) # Name
This defines the name property (nm
) of a person. The second
argument to rel
is always a list of relation classes (subclasses of
+relation
), optionally followed
by further arguments, causing relation daemon objects to be created and stored
in the class definition. These daemon objects control the entity's behavior
later at runtime.
Relation daemons are a kind of metadata, controlling the interactions between entities, and maintaining database integrity. Like other classes, relation classes can be extended and refined, and in combination with proper prefix classes a fine-grained description of the application's structure can be produced.
Besides primitive relation classes, like +Number
,
+String
or +Date
, there are
+Link
(unidirectional link),
+Joint
(bidirectional link) or +Hook
(object-local
index trees)
+Bag
)
+List
prefix class
+Blob
class for "binary large objects"
+Key
(unique
index), +Ref
(non-unique index) or +Idx
(full text
index)
+Sn
(modified soundex algorithm [knuth73]
for tolerant searches)
+Need
prefix class, for existence checks
+Dep
prefix class controlling dependencies between other
relations
In the case of the person's name (nm
) above, the relation object
is of type (+Need +Sn +Idx +String)
. Thus, the name of each person
in this demo database is a mandatory attribute (+Need
), searchable
with the soundex algorithm (+Sn
) and a full index
(+Idx
) of type +String
.
(rel pa (+Joint) kids (+Man)) # Father
(rel ma (+Joint) kids (+Woman)) # Mother
(rel mate (+Joint) mate (+Person)) # Partner
The attributes for father (pa
), Mother
(ma
) and partner (mate
) are all defined as
+Joint
s. A +Joint
is probably the most powerful
relation mechanism in PicoLisp; it establishes a bidirectional link between two
objects.
The above declarations say that the father (pa
) attribute
points to an object of type +Man
, and is joined with that object's
kids
attribute (which is a list of joints back to all his
children).
The consistency of +Joint
s is maintained automatically by the
relation daemons. These become active whenever a value is stored to a person's
pa
, ma
, mate
or kids
property.
For example, interesting things happen when a person's mate
is
changed to a new value. Then the mate
property of the old mate's
object is cleared (she has no mate after that). Now when the person pointed to
by the new value already has a mate, then that mate's mate
property
gets cleared, and the happy new two mates now get their joints both set
correctly.
The programmer doesn't have to care about all that. He just declares these
relations as +Joint
s.
The last four attributes of person objects are just static data:
(rel job (+Ref +String)) # Occupation
(rel dat (+Ref +Date)) # Date of birth
(rel fin (+Ref +Date)) # Date of death
(rel txt (+String)) # Info
They are all searchable via a non-unique index (+Ref
). Date
values in PicoLisp are just numbers, representing the day number (starting first
of March of the year zero).
A method url>
is defined:
(dm url> ()
(list "!person" '*ID This) )
It is needed later in the GUI, to cause a click on a link to switch to that object.
The classes +Man
and +Woman
are subclasses of
+Person
:
(class +Man +Person)
(rel kids (+List +Joint) pa (+Person)) # Children
(class +Woman +Person)
(rel kids (+List +Joint) ma (+Person)) # Children
They inherit everything from +Person
, except for the
kids
attribute. This attribute joins with the pa
or
ma
attribute of the child, depending on the parent's gender.
That's the whole data model for our demo database application.
It is followed by a call to dbs
("database sizes"). This call is optional. If it is not present, the whole
database will reside in a single file, with a block size of 256 bytes. If it is
given, it should specify a list of items, each having a number in its CAR, and a
list in its CDR. The CARs taken together will be passed later to pool, causing an individual database file with that
size to be created. The CDRs tell what entity classes (if an item is a symbol)
or index trees (if an item is a list with a class in its CAR and a list of
relations in its CDR) should be placed into that file.
A handful of access functions is provided, that know about database relationships and thus allows higher-level access modes to the external symbols in a database.
For one thing, the B-Trees created and maintained by the index daemons can be used directly. Though this is rarely done in a typical application, they form the base mechanisms of other access modes and should be understood first.
The function tree
returns the tree
structure for a given relation. To iterate over the whole tree, the functions
iter
and scan
can be used:
(iter (tree 'dat '+Person) '((P) (println (datStr (get P 'dat)) (get P 'nm))))
"1770-08-03" "Friedrich Wilhelm III"
"1776-03-10" "Luise Augusta of Mecklenburg-Strelitz"
"1797-03-22" "Wilhelm I"
...
They take a function as the first argument. It will be applied to all objects found in the tree (to show only a part of the tree, an optional begin- and end-value can be supplied), producing a simple kind of report.
More useful is collect
; it
returns a list of all objects that fall into a range of index values:
: (collect 'dat '+Person (date 1982 1 1) (date 1988 12 31))
-> ({2-M} {2-L} {2-E})
This returns all persons born between 1982 and 1988. Let's look at them with
show
:
: (more (collect 'dat '+Person (date 1982 1 1) (date 1988 12 31)) show)
{2-M} (+Man)
nm "William"
dat 724023
ma {2-K}
pa {2-J}
job "Heir to the throne"
{2-L} (+Man)
nm "Henry"
dat 724840
ma {2-K}
pa {2-J}
job "Prince"
{2-E} (+Woman)
nm "Beatrice"
dat 726263
ma {2-D}
job "Princess"
pa {2-B}
If you are only interested in a certain attribute, e.g. the name, you can return it directly:
: (collect 'dat '+Person (date 1982 1 1) (date 1988 12 31) 'nm)
-> ("William" "Henry" "Beatrice")
To find a single object in the database, the function db
is used:
: (db 'nm '+Person "Edward")
-> {2-;}
If the key is not unique, additional arguments may be supplied:
: (db 'nm '+Person "Edward" 'job "Prince" 'dat (date 1964 3 10))
-> {2-;}
The programmer must know which combination of keys will suffice to specify the object uniquely. The tree search is performed using the first value ("Edward"), while all other attributes are used for filtering. Later, in the Pilog section, we will show how more general (and possibly more efficient) searches can be performed.
The only types of GUI supported by the PicoLisp application server framework is either dynamically generated (but static by nature) HTML, or an interactive XHTML/CSS framework with the optional use of JavaScript.
Before we explain the GUI of our demo database application, we present a
minimal example for a plain HTML-GUI in @doc/hello.l
. Start the application server as:
$ pil @lib/http.l --server 8080 @doc/hello.l -wait
Now point your browser to the address 'http://localhost:8080
'. You should see a
very simple HTML page. You can come back here with the browser's BACK button.
You can call the page repeatedly, or concurrently with many clients if you
like. To terminate the server, you have to send it a TERM signal (e.g.
'killall pil
'), or type the Ctrl-C
key in the console
window.
In our demo database application, a single function person
is
responsible for the whole GUI. Again, please look at @doc/family.l
.
To start the database and the application server, call:
$ pil family.l -main -go +
As before, the database is opened with main
. The function
go
is also defined in @doc/family.l
:
(de go ()
(server 8080 "!person") )
It starts the HTTP server listening on TCP port 8080 (we did a similar thing
in our minimal GUI example above directly on the command line). Each connect to
that port will cause the function person
to be invoked.
Again, point your browser to the address 'http://localhost:8080
'.
You should see a new browser window with an input form created by the
function person
. We provided an initial database in "family/[1-4]".
You can navigate through it by clicking on the pencil icons besides the input
fields.
The chart with the children data can be scrolled using the down
(v
) and up (^
) buttons.
A click on the button "Select" below opens a search dialog. You can scroll through the chart as before. Again, a click on a pencil will jump to that person. You can abort the dialog with a click on the "Cancel"-button.
The search fields in the upper part of the dialog allow a conjunctive search. If you enter "Edward" in the "Name" field and click "Search", you'll see all persons having the string "Edward" in their name. If you also enter "Duke" in the "Occupation" field, the result list will reduce to only two entries.
To create a new person, press the "New Man" or "New Woman" button. A new empty form will be displayed. Please type a name into the first field, and perhaps also an occupation and birth date. Any change of contents should be followed by a press on the "Done" button, though any other button (also Scroll or Select-buttons) will also do.
To assign a father attribute, you can either type a name directly into
the field (if that person already exists in the database and you know the exact
spelling), or use the "Set"-button (->
) to the left of that
field to open the search dialog. If you type in the name directly, your input
must exactly match upper and lower case.
Alternatively, you may create a new person and assign a child in the "Children" chart.
On the console where you started PicoLisp, there should a prompt have
appeared just when the browser connected. You can debug the application
interactively while it is running. For example, the global variable
*Top
always contains the top level GUI object:
: (show *Top)
To take a look at the first field on the form:
: (show *Top 'gui 1)
A production application would be started in a slightly different way:
$ pil family.l -main -go -wait
In that case, no debug prompt will appear. In both cases, however, two
pil
processes will be running now. One is the initial server
process which will continue to run until it is killed. The other is a child
process holding the state of the GUI in the browser. It will terminate some time
after the browser is closed, or when (bye)
or a Ctrl-D
is entered at the
PicoLisp prompt.
Now back to the explanation of the GUI function person
:
(de person ()
(app)
(action
(html 0 (get (default *ID (val *DB)) 'nm<EMAIL_ADDRESS>NIL
(form NIL
(<h2> (<id> (: nm)))
For an in-depth explanation of that startup code, please refer to the guide to PicoLisp Application Development.
All components like fields and buttons are controlled by form
.
The function gui
creates a single GUI component and takes the type
(a list of classes) and a variable number of arguments depending on the needs of
these classes.
(gui '(+E/R +TextField) '(nm : home obj) 40 "Name")
This creates a +TextField
with the label "Name" and a length of
40 characters. The +E/R
(: Entity/Relation) prefix class connects
that field to a database object, the nm
attribute of a person in
this case, so that the person's name is displayed in that text field, and any
changes entered into that field are propagated to the database automatically.
(gui '(+ClassField) '(: home obj) '(("Male" +Man) ("Female" +Woman)))
A +ClassField
displays and changes the class of an object, in
this case the person's sex from +Man
to +Woman
and
vice versa.
As you see, there is no place where explicit accesses to the database have to
be programmed, no select
or update
. This is all
encapsulated in the GUI components, mainly in the +E/R
prefix
class. The above function person
is fully functional as we present
it and allows creation, modification and deletion of person objects in the
database.
The two buttons on the bottom right generate simple reports:
The first one shows all contemporaries of the person that is currently displayed, i.e. all persons who did not die before, or were not born after that person. This is a typical PicoLisp report, in that in addition to the report's HTML page, a temporary file may be generated, suitable for download (and import into a spread sheet), and from which a PDF can be produced for print-out.
In PicoLisp, there is not a real difference between a plain HTML-GUI and a
report. Again, the function html
is used to generate the page.
The second report is much simpler. It produces a recursive structure of the family.
In both reports, links to the person objects are created which allow easy navigation through the database.
This sections explains some cases of using Pilog in typical application programming, in combination with persistent objects and databases. Please refer to the Pilog section of the PicoLisp Reference for the basic usage of Pilog.
Again, we use our demo application @doc/family.l
that was introduced in the Database Programming section.
Normally, Pilog is used either interactively to query the database during
debugging, or in applications to generate export data and reports. In the
following examples we use the interactive query front-end functions ?
and select
. An application will use goal
and prove
directly, or use convenience functions
like pilog
or solve
.
All Pilog access to external symbols is done via the two predicates db/3
and select/3
.
db/3
corresponds to the Lisp-level
functions db
and collect
, as it derives its data from a
single relation. It can be used for simple database queries.
select/3
provides for
self-optimizing parallel access to an arbitrary number of relations. There is
also a Lisp front-end function select
, for convenient calls to the Pilog
select
predicate.
A predicate show/1
is pre-defined
for debugging purposes (a simple glue to the Lisp-level function
show
, see Browsing). Searching with db/3
for all persons having the string "Edward"
in their name:
: (? (db nm +Person "Edward" @P) (show @P))
{2-;} (+Man)
nm "Edward"
ma {2-:}
pa {2-A}
dat 717346
job "Prince"
@P={2-;}
{2-1B} (+Man)
nm "Albert Edward"
kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
job "Prince"
mate {2-f}
fin 680370
dat 664554
@P={2-1B}
... # more results
To search for all persons with "Edward" in their name who are married to somebody with occupation "Queen":
: (? (db nm +Person "Edward" @P) (val "Queen" @P mate job) (show @P))
{2-1B} (+Man)
mate {2-f}
nm "Albert Edward"
kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
job "Prince"
fin 680370
dat 664554
@P={2-1B}
-> NIL # only one result
If you are interested in the names of "Albert Edward"'s children:
: (? (db nm +Person "Albert Edward" @P) (lst @K @P kids) (val @Kid @K nm))
@P={2-1B} @K={2-1C} @Kid="Beatrice Mary Victoria"
@P={2-1B} @K={2-1D} @Kid="Leopold George Duncan"
@P={2-1B} @K={2-1E} @Kid="Arthur William Patrick"
@P={2-1B} @K={2-1F} @Kid="Louise Caroline Alberta"
@P={2-1B} @K={2-1G} @Kid="Helena Augusta Victoria"
@P={2-1B} @K={2-1H} @Kid="Alfred Ernest Albert"
@P={2-1B} @K={2-1I} @Kid="Alice Maud Mary"
@P={2-1B} @K={2-g} @Kid="Victoria Adelaide Mary"
@P={2-1B} @K={2-a} @Kid="Edward VII"
-> NIL
db/3
can do a direct index access
only for a single attribute (nm
of +Person
above). To
search for several criteria at the same time, select/3
has to be used:
: (?
(select (@P)
((nm +Person "Edward") (nm +Person "Augusta" pa)) # Generator clauses
(tolr "Edward" @P nm) # Filter clauses
(tolr "Augusta" @P kids nm) )
(show @P) )
{2-1B} (+Man)
kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
mate {2-f}
nm "Albert Edward"
job "Prince"
fin 680370
dat 664554
@P={2-1B}
-> NIL
select/3
takes a list of
generator clauses which are used to retrieve objects from the database, and a
number of normal Pilog filter clauses. In the example above the generators are
(nm +Person "Edward")
to generate persons with "Edward" in
their names, and
(nm +Person "Augusta" pa)
to find persons with "Augusta"
in their names and generate persons using the pa
("father")
attribute.
All persons generated are possible candidates for our selection. The
nm
index tree of +Person
is traversed twice in
parallel, optimizing the search in such a way that successful hits get higher
priority in the search, depending on the filter clauses. The process will stop
as soon as any one of the generators is exhausted. Note that this is different
from the standard Prolog search algorithm.
The filter clauses in this example both use the pre-defined predicate
tolr/3
for tolerant string
matches (according either to the soundex algorithm (see the section Database Programming) or to substring matches), and filter
objects that
(tolr "Edward" @P nm)
, and
(tolr "Augusta" @P
kids nm)
A more typical and extensive example for the usage of select
can
be found in the qPerson
function in @doc/family.l
. It is used in the search dialog of the
demo application, and searches for a person with the name, the parents' and
partner's names, the occupation and a time range for the birth date. The
relevant index trees in the database are searched (actually only those trees
where the user entered a search key in the corresponding dialog field), and a
logical AND of the search attributes is applied to the result.
For example, press the "Select" button, enter "Elizabeth" into the "Mother" search field and "Phil" in the "Partner" search field, meaning to look for all persons whose mother's name is like "Elizabeth" and whose partner's name is like "Phil". As a result, two persons ("Elizabeth II" and "Anne") will show up.
In principle, db/3
can be seen as a
special case of select/3
. The
following two queries are equivalent:
: (? (db nm +Person "Edward" @P))
@P={2-;}
@P={2-1B}
@P={2-R}
@P={2-1K}
@P={2-a}
@P={2-T}
-> NIL
: (? (select (@P) ((nm +Person "Edward"))))
@P={2-;}
@P={2-1B}
@P={2-R}
@P={2-1K}
@P={2-a}
@P={2-T}
-> NIL
For convenience, a select
Lisp
glue function is provided as a front-end to the select
predicate.
Note that this function does not evaluate its arguments (it is intended for
interactive use), and that it supports only a subset of the predicate's
functionality. The syntax resembles SELECT in the SQL language, for example:
# SELECT * FROM Person
: (select +Person) # Step through the whole database
{2-o} (+Man)
nm "Adalbert Ferdinand Berengar Viktor of Prussia"
dat 688253
ma {2-j}
pa {2-h}
fin 711698
{2-1B} (+Man)
nm "Albert Edward"
dat 664554
job "Prince"
mate {2-f}
kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
fin 680370
...

# SELECT dat, fin, p1.nm, p2.nm
# FROM Person p1, Person p2
# WHERE p1.nm LIKE "%Edward%"
# AND p1.job LIKE "King%"
# AND p1.mate = p2.mate -- Actually, in a SQL model we'd need
# -- another table here for the join
: (select dat fin nm (mate nm) +Person nm "Edward" job "King")
"1894-06-23" "1972-05-28" "Edward VIII" "Wallace Simpson" {2-T}
"1841-11-09" NIL "Edward VII" "Alexandra of Denmark" {2-a}
-> NIL
In addition (just to stay with the SQL terminology ;-), there is also an
update
function. It is a front-end
to the set!>
and put!>
transaction methods, and
should be used when single objects in the database have to be modified by hand.
In principle, it would also be possible to use the edit
function to modify a database object. This
is not recommended, however, because edit
does not know about
relations to other objects (like Links, Joints and index trees) and may easily
cause database corruption.
In the most general case, the value of a property in a database object is
changed with the put!>
method. Let's look at "Edward" from the
previous examples:
: (show '{2-;})
{2R} (+Man)
job "Prince"
nm "Edward"
dat 717346
ma {2-:}
pa {20A}
-> {2-;}
We might change the name to "Johnny" with put!>
:
: (put!> '{2-;} 'nm "Johnny")
-> "Johnny"
However, an easier and less error-prone prone way - especially when more than
one property has to be changed - is using update
. It presents the value (the list of
classes) and then each property on its own line, allowing the user to change it
with the command line editor.
Just hitting ENTER will leave that property unchanged. To modify it, you'll typically hit ESC to get into command mode, and move the cursor to the point of change.
For properties with nested list structures (+List +Bag
),
update
will recurse into the data structure.
: (update '{2-;})
{2-;} (+Man) # ENTER
nm "Johnny" # Modified the name to "Johnny"
ma {2-:} # ENTER
pa {2-A} # ENTER
dat 1960-03-10 # Modified the year from "1964" to "1960"
job "Prince" # ENTER
-> {2-;}
All changes are committed immediately, observing the rules of database synchronization so that any another user looking at the same object will have his GUI updated correctly.
To abort update
, hit Ctrl-X
.
If only a single property has to be changed, update
can be
called directly for that property:
: (update '{2-;} 'nm)
{2-;} nm "Edward"
...
[knuth73] Donald E. Knuth: ``The Art of Computer Programming'', Vol.3, Addison-Wesley, 1973, p. 392


GRNET - Firewall on Demand
{% blocktrans %}Welcome to GRNET's FoD service.{% endblocktrans %}
{% trans "What" %}?
{% blocktrans %}If you are new to the service, take some time to read the{% endblocktrans %} {% trans "Service Description" %}
{% blocktrans %}Before asking why? take some time to look at the{% endblocktrans %} {% trans "Service Terms" %}
{% trans "How" %}?
{% blocktrans %}If you have properly set your Shibboleth attributes, you may proceed{% endblocktrans %}
{% trans "Help" %}?
{% blocktrans %}For troubleshooting info and remarks do not hesitate to contact GRNET's Helpdesk.{% endblocktrans %}


Email<EMAIL_ADDRESS>to contact me or ask any questions.
For any inquiries or questions related to programming or my projects feel free to contact me via my GitHub.


Beep Box is a Flash-based tool for sketching and sharing chiptune melodies.
You can insert or delete notes by clicking on the gray rows at the top. Beep Box automatically plays the notes out loud for you. Drag horizontally in this area to adjust the duration of notes. Drag vertically on a note to bend its pitch, or drag vertically above or below the note to adjust its volume. Click above or below an existing note to add a rapid arpeggio/trill.
All notes go into numbered patterns, and the patterns are arranged in a sequence, making a song. You can select a new bar to edit by clicking once on a number below the note area. You can swap the pattern assigned to that bar by clicking again on the selected bar. There are four rows of bars representing different channels that can play at the same time. The gray channel is for drums only.
All song data is packaged into the URL text at the top of your browser. As you make changes to the song, the text after the "#" in the URL is updated to reflect your changes. When you are satisfied with your song, copy and paste the current URL to save and share your song. Re-enter the URL into your browser to load the song again. After loading any song, you are welcome to modify it further.
When Beep Box has focus (click in the Flash rectangle above), you can use these keyboard shortcuts:
Spacebar: Pause or Resume
Z: Undo
Y or Shift Z: Redo
C: Copy the current pattern
V: Paste the current pattern
[ ]: Move the playhead backward and forward
Arrow Keys: Change which bar is selected
1-8: Reassign a pattern to the currently selected bar
Beep Box is developed by John Nesky. Follow his twitter account for updates.
You can download an offline version of Beep Box (right click and select "Save As...") to use when you don't have access to the internet. The features are otherwise the same. You can open BeepBoxOffline.swf in a browser tab to run it, or you can install a Flash Projector to run swf files without a browser.
You can also download and use the source code under the MIT license. You can use the synth code to play Beep Box songs in your own Flash projects.
Neither John Nesky nor Beep Box assume responsibility for any copyrighted material played on Beep Box. No songs are ever received, recorded, or distributed by Beep Box's servers. All song data is contained in the URL after the hash (#) mark, and Beep Box running inside your browser simply converts the song data into sound waves, just like how MP3 players convert MP3 files into sound waves.


Major/New Features
Rails 5 support
Spree 3.2
is now compatible with Rails 5
compared to 3.1
which used to run on Rails 4.2
.
Thanks to that you can start using all of the new great features available in Rails 5
Contributed by Spark Solutions & Vinsol & John Hawthorn
Products Tagging
You can now tag Products additionally to just using Taxons. Tagging module uses acts-as-taggable-on
gem. You can easily fetch a list of Products associated to any given tag(s) which should be very helpful for creating new dynamic products listings.
Contributed by Vishal Zambre
Promo code applier on Cart
Discount code applier was brought back to the Cart view in customer frontend. Now enhanced, more user friendly and using API V1.
Contributed by Vinsol
Extended Google Analytics Enhanced Ecommerce integration
Spree now passes more meaningful information into Google Analytics when adding Products to Cart like:
- product category name
- product brand name
- variant description
Contributed by Spark Solutions
New Spree open source branding
We’ve changed logo for default customer frontend and Admin Panel to differentiate Spree Open Source project from Spree Commerce (company).
Contributed by Spark Solutions
Lighter and more user-friendly Admin Panel
We’ve removed a lot of unused, deprecated, outdated code and assets from the Admin Panel, overall reducing the codebase by a lot. We’ve also fixed a huge amount of UX issues like missing validation, bad navigation or lack of thereof and so on.
Contributed by Spark Solutions
Semantic versioning for future Extensions
We’re changing how extensions dependencies work. Previously you had to match
extension branch to Spree branch. Starting from now master
branch of all
generated extensions will work with Spree >= 3.1
and < 4.0
. Thanks to
that we’re dropping versioning of extensions same as Spree and using
standard Semantic versioning.
Contributed by Spark Solutions
More developer-friendly Extension generator
Extension template used by the generator includes now Travis CI config with settings to test extension against Spree 3.1, 3.2 & 3.3 (edge), PostgreSQL, MySQL, Ruby 2.2 & 2.3 thanks to Appraisals gem by thoughtbot.
Contributed by Spark Solutions
Upgrade
Update your Rails version to 5.0
Please follow the official Rails guide to upgrade your store.
Update Gemfile
gem 'spree', '~> 3.2.0' gem 'spree_auth_devise', '~> 3.2.0' gem 'spree_gateway', '~> 3.2.0'
Update your extensions
We’re changing how extensions dependencies work. Previously you had to match
extension branch to Spree branch. Starting from now master
branch of all
spree-contrib
extensions should work with Spree >= 3.1
and < 4.0
. Please change
your extensions in Gemfile eg.:
from:
gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero', branch: '3-1-stable'
to:
gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero'
Run bundle update
Install missing migrations
rails spree:install:migrations rails spree_auth:install:migrations rails spree_gateway:install:migrations
Run migrations
rails db:migrate
Other Gotchas
Ruby >= 2.2.2 required
As Rails 5 is now a dependency it requires at least Ruby 2.2.2 to run. Ruby 2.3 is also supported.
Noteworthy Changes
Also please review each of the noteworthy changes, and ensure your customizations or extensions are not effected. If you are affected by a change, and have any of your own tips please submit a PR to help the next person!
Full Changelog
You can view the full changes using Github Compare.
Noteworthy Changes
-
Removed previously deprecated Spree CMD installer
-
Removed unused
Spree::StoreController#apply_coupon_code
action -
Removed
Admin::SearchController
and pointed Admin Panel search actions to API endpoints -
Removed previously deprecated
Spree::ProductsHelper::line_item_description
-
Removed unused method
Spree::Admin::BaseHelper#attribute_name_for
-
Removed unused
Spree::Admin::InventorySettingsHelper
-
Removed unused
Spree::Admin::TablesHelper
-
Removed unused
Spree::Admin::ProductsHelper
-
Removed unused method
Spree::Admin::NavigationHelper#collapse_sidebar_link
-
Removed unused method
Spree::Admin::NavigationHelper#configurations_menu_item
-
Moved
Spree::PromotionRulesHelper
toSpree::Admin::PromotionRulesHelper
-
Fixed permissions for Product associations management in Admin Panel
-
ActiveMerchant updated to
~> 1.59
-
Added
created_at
to Variant model -
Additional Admin Panel usability fixes
-
Allow order to transit from resumed state to returned state
-
Changed
state
translation key in Admin Panel tostatus
-
Fixed API pagination
per_page
andcurrent_page
values (now always returned as integer) -
Display Spree version in Admin Panel
By default, it’s displayed only for Admin users who can manage the current Store, but can be disabled altogether by changing preferences:
Spree::Config[:admin_show_version] = false
inconfig/initializers/spree.rb
-
New preferences for Admin Panel
per_page
settings, default value for all of them is nowKaminari.config.default_per_page
(by default25
)orders_per_page
renamed toadmin_orders_per_page
properties_per_page
renamed toproperties_per_page
promotions_per_page
renamed toadmin_promotions_per_page
customer_returns_per_page
renamed toadmin_customer_returns_per_page
- added
admin_users_per_page
-
Removed unused
Spree::Admin::UsersController#json_data
method -
Added validation errors and other UX fixes for return process in Admin Panel
-
Added GitGub issue template
-
Added revert and deactivate methods to allow actions to take place when a Promotion is removed from the Cart
-
Use
Spree::Money
to display values in Sales Total report -
Fixed filtering out Products by
discontinue_on
in Admin Panel products index -
Allow title separator to be customized
-
Additional fixes for Spree mounted in other then default
/
mountpoint -
Search for current Order in Frontend using guest token only
-
Deprecated
Spree::Calculator::FreeShipping
-
Added promotion rule for shipping country


Which is no different from other typical workplaces in this country.
In a gray and tall building, lots of windows lie on each other where one looks exactly the same as the one in front and behind it, making them hard to count from outside. You have got a security card to get in. Yes, the same old play-hard-to-get trick. Somehow it’s just never getting old.
After passing a mostly male dominant, middle-aged line of people in black and grey, and some security guards who are typically in blue shirts and black pants which light things up a bit, or not, you go straight to an elevator hall which is where I’d like to call “a hall of doors”.  All seem normal, and in order, and the same everywhere, which is good.
Then you step into a steel box with lots of buttons. Don’t panic when choosing which one to press. Act cool. Or else people will realize that you’re new here, which is not good. Newcomers often are “welcomed” in a quite distinctive manner here that sometimes you’d wish that there are no beginnings, and no ends, of anything to make life easier.
Another joyful “tink!” and you find yourself in a somewhat greyer and less shiny hall-of-doors that is contradicting with the sound earlier.  No hesitate, people hate that amateur look. So your head goes up, or down whatever, but choose your way left or right decisively and step forward quickly to your designated door.
Another door. Another security gateway. Another level to raise, or low, your self-esteem intentionally.
You touch your card. A normal “beep” sound welcomes you in. Good. Normal is good. People here only prefer normal things. Don’t try to make any fuss or any unexpected moves. Just do it normally here. You don’t want to bother anybody and neither do them.
The door is opened and in front of you are countless lines of grey-ish tables. Each one has a laptop or a PC and a heap of paper on it.  And the whole room is lit up by a very blurred light comes from the ceiling, because the windows are too far away and too tiny for the room for any sunshine to break in here.
You then again quickly locate your place and walk in a, guess what, grey carpet heading to it.
Nodding, “Shhhhh!” sounds everywhere. That’s how people here greet each other. It can be brutally translated as “Okay I know it’s you.  Sit up straight in your chair. Put your bag in a drawer right below your table. Then hang your jacket in a closet at a corner if it’s wintertime.  Look at yourself in the mirror. All suit up in black and white and grey. Okay, everything seems normal. Now come back to your desk and start a day.
Working. Typing. Nodding.
Meeting in grey rooms with heavy light-grey metal doors and metal tables also in the same shade of colors. Sometimes with blue chairs. And a whiteboard with some tidy makers that somebody is thoughtful enough to line up them exactly in the middle of a tray down below and next to a wiper. Also sitting at the corner is a TV and a projector, which are rarely used but when you do, try to go in and do some checking an hour before because people here don’t like unprepared and unthoughtful bastards who don’t automatically know what are their jobs and where are their places.
Typing. Chatting. Nodding. Bowing. Ringing sounds of phones somewhere. Then a melody to tell you that it’s lunchtime. For one hour. Rushing to line up in the nearest restaurant. Checking menu. Ordering. Waiting. Shoot! 30 mins passed. Waiting again. Eating in hurry. Security door. Security door. And back to work you go.
Typing. Clicking. Nodding. Copying. Meeting.
Another melody. Is that time to go home? Not yet! Look up to the head of your line. Has the big boss left yet? No? Then sit still.
Go to a convenience store nearby. Buy some snacks. Linger at “refresh corner” just to buy a canned coffee and smell cigarettes in the air and look out the window. Ah, the window. It’s already dark outside. Maybe it’s okay to leave now.
Tidying up. Bowing. Bowing. Bowing. Security door. Security door. Bowing again. What’s left to do today? Maybe finding a seat on your already crowded trains. If it’s too hopeless then just stand. Holding to your bag between your legs because there’s no other space. And let yourself be blank. And grey. And the same. And normal. Normal is good.
Tomorrow will be different, I hope. But no “bad” different! “Normal” different is good enough…


Home
Transactions
Accounts
Transactions for:
Opening Balance
Current Balance:
0.00
X
Create Voucher
Date:
Number:
ID
Date
Description
Amount From
Amount To
Other Account
Reference
X
0.00
0.00


I tried meditation before I start studying.
It was interesting that meditation is very good in many different ways and it is scientifically approved. Also, the way to create habits such as 'behaviour first and then attitude' were interesting too.
I found meditation improved my concentration on study and made me easy to control my emotions.
I want to try to make some good habits and try the Pomodoro time management technique.


|
Kellogg's Cornflakes"Is God a man with two arms and legs like me? Does He have eyes, a head? Does He have bowels? Well I do, and that makes me more wonderful than He is!" Kellogg's Cornflakes, the bland breakfast flakes that go almost instantly limp in milk were originally invented to bore you into such a deep coma that you would fall face down in the milk drenched flakes, drown, and thereby be spared the temptation and sin known as masturbation. Like many Christian conservatives before and since, Dr. John Harvey Kellogg believed that masturbation, and in fact all sexual excess, was sinful -- "sexual excess" here defined as "sex for anything beyond reproduction". For instance: after marrying, Kellogg chose to spend his honeymoon sequestered from his wife, valiantly striving to complete his his influential book Plain Facts for Old and Young: Embracing the Natural History and Hygiene of Organic Life (1892). Talk about your dull, soggy flakes. Kellogg himself seems to have solved the problem by redirecting his attentions to an obsessive fascination with cleansing the bowels. For Kellogg, the tube linking anus to lips was a seething quagmire of pollution, poisoning the mind and spirit as well as the body. Kellogg, a vegetarian himself, recommended abstaining from flesh and spicy foods, augmenting the diet with plenty of fiber, drinking lots of water, and irrigating with regular enemas of water with a yogurt chaser. And as director of the Battle Creek Sanitarium, Kellogg had ample license to apply his approach to many captive well-to-do neurotics in need of mental restablizing. According to Kellogg, 90 percent of all human ills originated in the bowels. One would think however that all 90 percent originated in the twiddling of the crotch, given the fury with which Kellogg attacked the humble practice of masturbation. In Plain Facts for Old and Young, he advised that the first line of defense was keeping children busy and constantly under surveillance -- that is, working them daily to the point of exhaustion. The vigilant parent must especially be aware of a child's goings on in the bathtub, on the toilet, or in bed, for solitude was a temptation to vice. Furthermore, all parents were urged to watch for such tell-tale "symptoms" of masturbation as bad posture (slumped shoulders), a fear of the opposite sex, and hanging out in groups with other children of the same gender. Stiffness in the hips in boys or a wiggly walk in girls were also clues. Also a child who suddenly became more bold -- or worse, more timid -- was surely a masturbator as well. To stop these hideous acts of depravity, Kellogg strongly advocated circumcision of young boys (note that, up until this era, most non-Jewish American boys were not circumcised), stating that the operation should be done without anesthesia because the remembered pain (and the soreness which followed for several weeks) would serve as a lasting reminder deterring the child from rummaging. Another deterrent recommended by Kellogg was to wire a boy’s foreskin together at the tip such that any mere erection would become very painful. The wire was of course to be attached by piercing the foreskin with a needle, with the wire following along in place of thread. For the multitude of American males who do not (thanks to Kellogg and his ilk) have a foreskin, it may be worth mentioning that the foreskin is considered to be much more sensitive to pain and pleasure than the bald penis you may currently own. But Kellogg did not single out only boys for torment -- perish the thought! Girls too must be prevented from self-pleasuring, at all costs. For girls Kellogg recommended that application of carbolic acid directly to the clitoris was:
an excellent means of allaying the abnormal excitement, and preventing the recurrence of the practice in those whose will-power has become so weakened that the patient is unable to exercise entire self-control. Of course, now medical doctors know that carbolic acid is extremely poisonous. When applied to the tissues, and when applied directly to muscle or nerve, it causes instant paralysis. And when swallowed undiluted, it produces violent gastro-enteritis, with vomiting and purging, followed by collapse, delirium, and often by convulsions and death. Nonetheless, if carbolic acid did not do the trick, Kellogg reasoned it was necessary to surgically remove the clitoris. He cites one such surgery, he performed at the request of the girl's father.  Kellogg and cliterodectomy were her only hope for continued life and salvation. The good doctor happily obliged. Although it is hard to judge whether Kellogg and similar theorists were the cause or merely the voice of 19th century Americans' surging hysteria over masturbation, we can certainly see that the shadow of this era has lingered in our culture for over a century. Only now with the threat of HIV looming more menacingly has our society begun to switch gears and tout masturbation as a good complement to abstaining from premarital sex -- but only because horny teens were having trouble abstaining without jacking off. And Christian bible scholars are revealing the all new politically correct truth that the bible doesn't really condemn masturbation at all! Surely Kellogg is rolling over in his grave at this latest theological development. But at least people still like his cornflakes. But wait! The cornflakes we consume today are not John Kellogg's simple flakes of corn! They are actually an adulterated version of his original creation, spiked with sugar and who knows what else. In fact the Kelloggs' breakfast cereals were manufactured by his brother Will Kellogg, whom he sued for trotting out the Kellogg name on something much more palatable than the original gruel served up at his Battle Creek Sanitarium. No doubt this insidious corruption of American breakfast cereal explains why Americans are the horny bastards they are today.
|


@()(implicit request: RequestHeader, context: model.ApplicationContext) @import conf.AdminConfiguration.pa @import org.joda.time.{DateTime, LocalDate} @import views.support.GuDateFormatLegacy @admin_main("Football Troubleshooter", isAuthed = true) { @defining((GuDateFormatLegacy(DateTime.now(), "yyyyMMdd"), "Premier League", "100")){ case (today, competition, competitionId) =>
How to access the raw feeds to determine if a problem lies in the feeds or in the application
The current API host is @pa.footballHost and the API key is @pa.footballApiKey.
To log a support call with PA email customer.services@@pressassociation.com or call 01430 455337
If in doubt raise a support ticket. (it's what we pay them for)
The PA API explorer is here. Select 'Football API v1.5' from the drop-down menu, and enter the key supplied above into the key text box.
This is the feed you are most likely to be interested in. This feed shows detailed information on today's matches and is the feed we use while the match is live.
A single call to this api loads match data for today for all competitions and the date format is YYYYMMDD.
This api call also includes today's fixtures and results.
Here is the API call for today's live matches:
@pa.footballHost/competitions/matchDay/@pa.footballApiKey/@todayThis shows us all the competitions we have access to. You can use it to find the ID of a competition that we can use to access other feeds.
<EMAIL_ADDRESS>will first appear in the fixtures feed. We query each competition separately for all upcoming fixtures.
Here is the API call for all upcoming fixtures in the @competition (id @competitionId). You can get other competition IDs from the Competitions feed above.
@pa.footballHost/competition/fixtures/@pa.footballApiKey/@competitionIdShows the results for completed matches. We query each competition separately for results.
Here is the API call for results in the @competition (id @competitionId). You can get other competition IDs from the Competitions feed above and the date format is YYYYMMDD.
@pa.footballHost/competition/results/@pa.footballApiKey/@competitionId/@GuDateFormatLegacy(new LocalDate(2014, 6, 12), "yyyyMMdd")Shows all the stats we use to populate the league tables.
Here is the API call for the league table for @competition (id @competitionId). You can get other competition IDs from the Competitions feed above and the date format is YYYYMMDD.
@pa.footballHost/competition/leagueTable/@pa.footballApiKey/@competitionId/@todayDetailed match stats for a specific match. You would get the match ID from either the fixtures or matchday or results feed.
<EMAIL_ADDRESS>line ups for a specific match, containing team colours (before we apply darkening, and missing colours default to #eeeeee).
<EMAIL_ADDRESS>} }


UL
This is to be used in the BODY Tag.
This tag is used to create Unordered or Bulleted Lists
.
This is a Container Tag and thus has to be closed.
Attributes
- TYPE :
- "disc" :
To create lists as
....
(This is the Default Type )
- "circle" :
To create lists as
....
- "square" :
To create lists as
....
Syntax

 ...Text...

 ...Text...
....

Example

 List Item1

 List Item2

Effect
List Item1
List Item2
Home
About


Results - VS Code vs PyCharm
Posted on Tue 02 February 2021 in Misc
I asked Reddit about text editors vs IDEs. In particular, I asked VS Code users why they preferred it over IDEs like PyCharm, and then I asked PyCharm users why they preferred it over text editors like VS Code. The results were very interesting.
VSCode users: Why do you prefer it over PyCharm?

Results: VS Code
Among VS Code users, the following reasons were listed most:
Results: PyCharm
And among PyCharm users, the following reasons were most common:
Conclusion
Looking at the above, I can conclude a few things:
-
Users who work with multiple languages frequently prefer VS Code, whereas users who work mainly with Python prefer PyCharm.
-
Users who don't want to spend much time on set up and configuration prefer PyCharm, because of it's many out-of-the-box features.
-
Users who like flexibility prefer VS Code because of its vast plugin ecosystem that lets them add virtually any needed functionality.
-
The price of PyCharm Professional seems to be a significant factor.
-
PyCharm users say that such deep language integration cannot be found in any text editor.
I myself am a PyCharm Pro user. The price is worth it to me, and my top reasons why I prefer it are:
-
Deep language integration: Even though Python support in VS Code is very good, PyCharm has even better integration. This ranges from smart autocomplete to stellar refactoring tools. To a limited degree, VS Code has these as well (with plugins), but PyCharm takes it to another level.
-
I like not having to look for and install multiple plugins before having the functionality I need. Plugins also make you dependent on 3rd parties, whereas in PyCharm everything is built-in and always works seamlessly.


Hold space key or click/touch to run timer.
Newest solved time
{{timeListFromStorage.slice().reverse()[0].time}}
Best
00.00
{{ bestSolvedTimeReactive }}
Worst
00.00
{{ worstSolvedTimeReactive }}
This web app is underdevelopment | feel free to contribute


It all began about 11:00 at night, I had just got back from Wal-Mart with my friend, we were ready to extract some hydrocodone. I had 14 10 milligram Watson hydrocodone pills. (Watson is a generic brand of pharmacueticals). If we had ate 7 a piece, we wouldve been f**ked for sure due to acetamineophen, so I extracted them using the extraction method described in the codeine FAQ. It took about 2 hours to fully extract, but it was worth it.
12:30
My friend and I take turns taking swigs of the solution, we get about 3 swigs a piece, I guess we got an even dose, I think we did anyway. I figured we lost some hydrocodone in the extraction, so I didn't know what was gonna happen.
12:40
We smoke a bowl of marijuana out of a homemade bong. Then, I get out my glass pipe and we smoke 2 more bowls.
12:55
I start spinning very fast, the buzz is like being very very drunk and floating at the same time. I am sure that I am going to puke, I run to the bathroom, but I don't puke and I feel better within seconds.
1:10
My friend and I walk upstairs to his room, I can't walk straight. I feel some nausea, so I lay down, we turn on Dark Side of the Mood by Pink Floyd and start to drift away. My friend chats on the computer most of the night
Heres what the buzz is like:
Emmense physical and mental high. Feels like I am floating.
Some nausea, but I am laying down, and it goes away while I am.
Music is the greatest thing, I start drifting away to the cd and snap back into reality after a while.
It's very hard for me to keep my eyes open.
Euphoria is intense and great.
I have lost all track of time.
3:00? (I am not sure cause time went so fast)
I suddenly feel like a hole has been torn in my buzz, I am still high as hell, but I figure that the weed has worn off.
So, I smoke 2 more bowls with my friend and lay back down, the weed replenishes my buzz and it's just as good as before.
5:00
My friend hits the sack, both of us still high as hell, we probably didn't actually get to sleep until about 5:30, but I didn't want to sleep.
7:00
We are woke up by my friends grandma, my friend is supposed to go somewhere, but he fakes sick and gets to stay home. We are both still very high, I try not to go back to sleep, but I do.
11:00
I wake up with a slight hangover, nothing compared to a night of beer drinking though. I do not feel sick at all, just a bit hungry and very thirsty.
I recommend hydrocodone to anyone, but extract it!
If you don't extract it, you are heading towards a night in the hospital.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


网站首页
搜索
所有博文
博文分类
关于本网站
A Guide to Elementary Chemistry: For Beginners
作者：
Le Roy C. Cooley
分类：
化学 - 基础化学
出版商：Ivison, Blakeman, Taylor & Co.
语言：英语
百度盘下载
提取码是：29a6
书籍目录
Observation and Experiment
Chemical changes
Chemistry of Combustion
Chemistry of Water
Chemistry of the Atomsphere
Compounds of Nitrogen, Hydrogen, and Oxygen
The Composition of Plants
Elements, Molecules, and Atoms
Acids, Bases, and Salts
Chlorine and the Chlorides
Sulphur and Its Compounds
Phosphorus, and the Nitrogen Group
Silicon, and the Carbon Group
Valence
The Metals
The Potassium Group
The Calcium Group
Metals of the Zinc Group
The Iron Group
Aluminum
The Antimony Group
Tin and Lead
The Copper Group
Gold and Platinum
Classification
书籍简介
本书pdf是文字识别版，影印质量还行。
Observation and Experiment
Chemical changes
Chemistry of Combustion
Chemistry of Water
Chemistry of the Atomsphere
Compounds of Nitrogen, Hydrogen, and Oxygen
The Composition of Plants
Elements, Molecules, and Atoms
Acids, Bases, and Salts
Chlorine and the Chlorides
Sulphur and Its Compounds
Phosphorus, and the Nitrogen Group
Silicon, and the Carbon Group
Valence
The Metals
The Potassium Group
The Calcium Group
Metals of the Zinc Group
The Iron Group
Aluminum
The Antimony Group
Tin and Lead
The Copper Group
Gold and Platinum
Classification


Generates memorable phrases using the Wordnik API. Phrases have sentence structure similar to Noam Chomsky's famous 'Colorless green ideas sleep furiously' and are not guaranteed to make sense