# STklos Reference Manual 1. Introduction

Contents
| *Top*
1 | Introduction
1.1 | Overview of STklos
1.2 | Lexical Conventions
1.3 | Basic Concepts
2 | Expressions
3 | Program structure
4 | Standard Procedures
5 | Regular Expressions
6 | Pattern Matching
7 | Exceptions and Conditions
8 | STklos Object System
9 | Threads, Mutexes and Condition Variables
10 | Customizations
11 | The ScmPkg Package System
12 | Foreign Function Interface
13 | Using the SLIB package
14 | SRFIs
15 | Index
| Bibliography
- | ### 1.1 Overview of STklos STklos is the successor of STk [6], a Scheme interpreter which was tightly connected to the Tk graphical toolkit [11]. STk had an object layer which was called STklos. At this time, STk was used to denote the base Scheme interpreter and STklos was used to denote its object layer, which was an extension. For instance, when programming a GUI application, a user could access the widgets at the (low) Tk level, or access them using a neat hierarchy of classes wrapped in STklos. Since the object layer is now more closely integrated with the language, the new system has been renamed STklos and STk is now used to designate the old system. Compatibility with STk: STklos has been completely rewritten and as a consequence, due to new implementation choices, old STk programs are not fully compatible with the new system. However, these changes are very minor and adapting a STk program for the STklos system is generally quite easy. The only programs which need heavier work are programs which use Tk without objects, since the new preferred GUI system is now based on GTK+ [2]. Programmers used to GUI programming using STklos classes will find that both system, even if not identical in every points, share the same philosophy. ### 1.2 Lexical Conventions #### 1.2.1 Identifiers In STklos, identifiers which start (or end) with a colon "`:`" are considered as keywords. For instance `:foo` and `bar:` are STklos keywords, but `not:key` is not a keyword. See section Keywords for more information #### 1.2.2 Comments There are four types of comments in STklos: a semicolon "`;`" indicates the start of a comment. This kind of comment extends to the end of the line (as described in R5RS). multi-lines comment use the classical Lisp convention: a comment begins with "`#|`" and ends with "`|#`". This form of comment is now defined by SRFI-30 (Nested Multi-line Comments). a sharp sign followed by a semicolon "`#;`" comments the next Scheme expression. This is useful to comment a piece of code which spans multiple lines comments can also be introduced by "`#!`"''. Such a comment extends to the end of the line which introduces it. This extension is particularly useful for building STklos scripts. On most Unix implementations, if the first line of a script looks like this:
       #!/usr/local/bin/stklos -file
then the script can be started directly as if it was a binary program. STklos is loaded behind the scene and executes the script as a Scheme program. This form is compatible with the notation introduced in SRFI-22 (Running Scheme Scripts on Unix) Note that, as a special case, that the sequences "`#!key`", "`#!optional`" and "`#!rest`" are respectively converted to the STklos keywords "`:key`", "`:optional`" and "`:rest`". This permits to Scheme lambdas, which accepts keywords and optional arguments, to be compatible with DSSSL lambdas [10]. #### 1.2.3 Here Strings Here strings permit to easily enter multilines strings in programs. The sequence of characters #<< starts a here string. The characters following this sequence #<< until a newline character define a terminator for the here string. The content of the string includes all characters between the #<< line and a line whose only content is the specified terminator. No escape sequences are recognized between the starting and terminating lines. Example: the sequence
    #<<EOF
    abc
    def
      ghi
    EOF
is equivalent to the string
    "abc\ndef\n  ghi"
- #### 1.2.4 Other Notations STk accepts all the notations defined in R5RS plus "`[]`" Brackets are equivalent to parentheses. They are used for grouping and to build lists. A list opened with a left square bracket must be closed with a right square bracket (see section Pairs and lists). "`:`" a colon at the beginning or the end of a symbol introduces a keyword. Keywords are described in section Keywords. `#n=` is used to represent circular structures. The value given of n must be a number. It is used as a label, which can be referenced later by a `#n#` notation (see below). The scope of the label is the expression being read by the outermost `read`. `#n#` is used to reference some object previously labeled by a `#n=` notation; that is, `#n#` represents a pointer to the object labeled exactly by `#n=`. For instance, the object returned by the following expression
      (let* ((a (list 1 2))
             (b (cons 'x a)))
        (list a b))
  can also be represented in this way:
      (#0=(1 2) (x . #0#))
### 1.3 Basic Concepts See the original R5RS document for more informations on the basic concepts of the Scheme Programming Language.

This Html page has been produced by Skribe.
Last update Sat Dec 31 15:49:29 2011