Guile Scheme concepts
*********************

Most Scheme implementations go beyond what is specified in the R4RS document  (Remember?  R4RS is the Revised^4 report on the Algorithmic Language Scheme), mostly because R4RS does not give specifications (or even recommendations) regarding some issues that are quite important in practical programming.

Here is a list of how Guile implements some of these much-needed Scheme extensions; other Scheme implementations do so quite similarly.

Scheme slang
============

Even if you read some of the nice books on Scheme, or the R4RS report, you might not find some of the terms frequently used by Scheme hackers, both in the manual and in the news:comp.lang.scheme newsgroup.

Here is a glossary of some of the terms that make Scheme beginners and intermediate users say ``huh?''

thunk
     A Scheme procedure that takes no arguments.  In this example, thunk and another-thunk are both thunks:

          (define (thunk)
            (display "Dude, I'm a thunk!")
            (newline))
          (define another-thunk
            (lambda ()
              (display "Me too!\n")
              (newline)))

closure
     A closure is a procedure.  However, the term emphasizes the fact that a Scheme procedure remembers (or closes over) the variables that were visible when the lambda expression was evaluated.

     In the example below, we might refer to q as a closure, because it has closed over the value of x:

          (define p
            (lambda (x)
              (lambda (y)
                (+ x y))))
          (define q (p 5.7))

          (q 10)
          => 15.7

     However, strictly speaking, every Scheme procedure is really a closure, since it closes over the top-level environment.

alist
association list

plist
property list

Read-eval-print loops
=====================

To explicitly mention the Scheme read-eval-print loop (REPL) seems weird because we are all accustomed to firing up an interpreter and having it read and execute commands.

But the REPL is not specified in R4RS; rather, it is proposed by the Scheme Bible Structure and Interpretation of Computer Programs (also known as SICP), and implemented in some form in all Scheme interpreters.

[FIXME: Someone needs to tell me what needs to be said about Guile's REPL.]

Extra data types
================

The fundamental Scheme data types specified in R4RS are numbers (both exact and inexact), characters, strings, symbols, vectors, pairs and lists [FIXME: is this complete?].

Many Scheme interpreters offer more types, and Guile is no exception. Guile is based on Aubrey Jaffer's SCM interpreter, and thus inherits uniform arrays, [FIXME: any others?  How about records?].

On top of that, Guile allows you to add extra types, but that is covered in Adding types to Guile.  Here I will simply document all the extra Scheme types shipped with Guile.

Conventional arrays
-------------------

Uniform arrays
--------------

The motivation for uniform arrays in Scheme is performance.  A vector provides a performance increase over lists when you want a fixed-size indexable list.  But the elements in a vector can be of different types, and this makes for larger storage requirements and slightly lower performance.

A uniform array is similar to a vector, but all elements have to be of the same type.

arrays, uniform arrays, bit vectors:

 -- procedure: array-fill ra fill

 -- procedure: serial-array-copy! src dst

 -- procedure: serial-array-map ra0 proc [lra]

 -- procedure: array-map ra0 proc [lra]

 -- procedure: array-for-each proc ra0 [lra]

 -- procedure: array-index-map! ra proc

 -- procedure: array-copy! src dst

 -- procedure: array-copy! src dst

 -- procedure: array-copy! src dst

 -- procedure: array-copy! src dst

 -- procedure: array-copy! src dst

 -- procedure: array? ra [prot]

 -- procedure: array-rank ra

 -- procedure: array-dimensions ra

 -- procedure: dimensions->uniform-array dims prot fill ...

 -- procedure: make-shared-array ra mapfunc dims ...

 -- procedure: transpose-array arg ...

 -- procedure: enclose-array axes ...

 -- procedure: array-in-bounds? arg ...

 -- procedure: array-ref ra arg ..

 -- procedure: uniform-vector-ref vec pos

 -- procedure: array-set! ra obj arg ...

 -- procedure: uniform-array-set1! ua obj arg

 -- procedure: array-contents ra [strict]

 -- procedure: uniform-array-read! ra [port-or-fd] [start] [end]

 -- procedure: uniform-array-write! ra [port-or-fd] [start] [end]

 -- procedure: bit-count item seq

 -- procedure: bit-position item v k

 -- procedure: bit-set! v kv obj

 -- procedure: bit-count* v kv obj

 -- procedure: bit-invert v

 -- procedure: array->list ra

 -- procedure: list->uniform-array ndim prot list

 -- procedure: array-prototype ra

Unform arrays can be written and read, but read won't recognize them unless the optional read-sharp parameter is supplied, e.g,

     (read port #t read-sharp)

where read-sharp is the default procedure for parsing extended sharp notations.

Reading an array is not very efficient at present, since it's implemented by reading a list and converting the list to an array.

 -- Scheme type: uniform array

Bit vectors
-----------

Complex numbers
---------------

 -- Scheme type: complex
     Standard complex numbers.

Miscellaneous features
======================

 -- Function: defined? symbol
     Returns #t if a symbol is bound to a value, #f otherwise. This kind of procedure is not specified in R4RS because this thought

 -- Function: object-properties OBJ
     and so forth