~ chicken-core (chicken-5) 817afd5ac625dcbba1cab5b51ae0a2767097bbf5
commit 817afd5ac625dcbba1cab5b51ae0a2767097bbf5 Author: Peter Bex <peter@more-magic.net> AuthorDate: Sat Jun 6 17:38:26 2015 +0200 Commit: Mario Domenech Goulart <mario.goulart@gmail.com> CommitDate: Sat Jun 13 11:03:13 2015 -0300 Merge online wiki changes into the manual. diff --git a/manual/Extensions to the standard b/manual/Extensions to the standard index fd6fd234..7b3e20b4 100644 --- a/manual/Extensions to the standard +++ b/manual/Extensions to the standard @@ -25,9 +25,9 @@ Numerous non-standard macros are provided. See Extended DSSSL style lambda lists are supported. DSSSL parameter lists are defined by the following grammar: <parameter-list> ==> <required-parameter>* - [(#!optional <optional-parameter>*)] - [(#!rest <rest-parameter>)] - [(#!key <keyword-parameter>*)] + [#!optional <optional-parameter>*] + [#!rest <rest-parameter>] + [#!key <keyword-parameter>*] <required-parameter> ==> <ident> <optional-parameter> ==> <ident> | (<ident> <initializer>) diff --git a/manual/Getting started b/manual/Getting started index 68754a96..bc8f43ef 100644 --- a/manual/Getting started +++ b/manual/Getting started @@ -149,7 +149,7 @@ programs. === CHICKEN repositories, websites, and community The master CHICKEN website is -[[http://www.call-with-current-continuation.org]]. Here you can find +[[http://www.call-cc.org]]. Here you can find basic information about CHICKEN, downloads, and pointers to other key resources. @@ -183,8 +183,10 @@ can pretty much ignore the C compiler once you have installed it.) installed as part of the basic operating system, or should be available through the package management system (e.g., APT, Synaptic, RPM, or Yum, depending upon your Linux distribution). -* On Macintosh OS X, you will need the XCode tools, which you can download - at the Apple website. +* On Macintosh OS X, you will need the XCode tools, which were shipped + on the OS X DVD with older versions of the operating system, and are + installable from the App Store with recent versions of the operating + system. * On Windows, you have three choices: ** Cygwin ([[http://sourceware.org/cygwin/]]) provides a relatively full-featured Unix environment for Windows. CHICKEN works diff --git a/manual/The R5RS standard b/manual/The R5RS standard index b79a5462..d88294ab 100644 --- a/manual/The R5RS standard +++ b/manual/The R5RS standard @@ -1,3 +1,5 @@ +== The R5RS standard + This document describes CHICKEN's R5RS support, with a heavy emphasis on syntax and procedures. It is based directly on the ''Revised^5 Report on the Algorithmic Language Scheme''. @@ -864,6 +866,156 @@ which would result in an invalid procedure call. == Program structure +=== Programs + +A Scheme program consists of a sequence of expressions, definitions, +and syntax definitions. Expressions are described in chapter 4; +definitions and syntax definitions are the subject of the rest of the +present chapter. + +Programs are typically stored in files or entered interactively to a +running Scheme system, although other paradigms are possible; +questions of user interface lie outside the scope of this +report. (Indeed, Scheme would still be useful as a notation for +expressing computational methods even in the absence of a mechanical +implementation.) + +Definitions and syntax definitions occurring at the top level of a +program can be interpreted declaratively. They cause bindings to be +created in the top level environment or modify the value of existing +top-level bindings. Expressions occurring at the top level of a +program are interpreted imperatively; they are executed in order when +the program is invoked or loaded, and typically perform some kind of +initialization. + +At the top level of a program (begin <form1> ...) is equivalent to the +sequence of expressions, definitions, and syntax definitions that form +the body of the begin. + +=== Definitions + +Definitions are valid in some, but not all, contexts where expressions +are allowed. They are valid only at the top level of a <program> and +at the beginning of a <body>. + +A definition should have one of the following forms: + +* (define <variable> <expression>) + +* (define (<variable> <formals>) <body>) + +<Formals> should be either a sequence of zero or more variables, or a +sequence of one or more variables followed by a space-delimited period +and another variable (as in a lambda expression). This form is +equivalent to + + (define <variable> + (lambda (<formals>) <body>)). + +* (define (<variable> . <formal>) <body>) + +<Formal> should be a single variable. This form is equivalent to + + (define <variable> + (lambda <formal> <body>)). + +==== Top level definitions + +At the top level of a program, a definition + + (define <variable> <expression>) + +has essentially the same effect as the assignment expression + + (set! <variable> <expression>) + +if <variable> is bound. If <variable> is not bound, however, then the +definition will bind <variable> to a new location before performing +the assignment, whereas it would be an error to perform a set! on an +unbound variable. + + (define add3 + (lambda (x) (+ x 3))) + (add3 3) ===> 6 + (define first car) + (first '(1 2)) ===> 1 + +Some implementations of Scheme use an initial environment in which all +possible variables are bound to locations, most of which contain +undefined values. Top level definitions in such an implementation are +truly equivalent to assignments. + +==== Internal definitions + +Definitions may occur at the beginning of a <body> (that is, the body +of a lambda, let, let*, letrec, let-syntax, or letrec-syntax +expression or that of a definition of an appropriate form). Such +definitions are known as internal definitions as opposed to the top +level definitions described above. The variable defined by an internal +definition is local to the <body>. That is, <variable> is bound rather +than assigned, and the region of the binding is the entire <body>. For +example, + + (let ((x 5)) + (define foo (lambda (y) (bar x y))) + (define bar (lambda (a b) (+ (* a b) a))) + (foo (+ x 3))) ===> 45 + +A <body> containing internal definitions can always be converted into +a completely equivalent letrec expression. For example, the let +expression in the above example is equivalent to + + (let ((x 5)) + (letrec ((foo (lambda (y) (bar x y))) + (bar (lambda (a b) (+ (* a b) a)))) + (foo (+ x 3)))) + +Just as for the equivalent letrec expression, it must be possible to +evaluate each <expression> of every internal definition in a <body> +without assigning or referring to the value of any <variable> being +defined. + +Wherever an internal definition may occur (begin <definition1> ...) is +equivalent to the sequence of definitions that form the body of the +begin. + +=== Syntax definitions + +Syntax definitions are valid only at the top level of a +<program>. They have the following form: + + (define-syntax <keyword> <transformer spec>) + +<Keyword> is an identifier, and the <transformer spec> should be an +instance of syntax-rules. The top-level syntactic environment is +extended by binding the <keyword> to the specified transformer. + +There is no define-syntax analogue of internal definitions. + +Although macros may expand into definitions and syntax definitions in +any context that permits them, it is an error for a definition or +syntax definition to shadow a syntactic keyword whose meaning is +needed to determine whether some form in the group of forms that +contains the shadowing definition is in fact a definition, or, for +internal definitions, is needed to determine the boundary between the +group and the expressions that follow the group. For example, the +following are errors: + + (define define 3) + + (begin (define begin list)) + + (let-syntax + ((foo (syntax-rules () + ((foo (proc args ...) body ...) + (define proc + (lambda (args ...) + body ...)))))) + (let ((x 3)) + (foo (plus x y) (+ x y)) + (define foo x) + (plus foo x))) + == Standard procedures This chapter describes Scheme's built-in procedures. The initial (or diff --git a/manual/The User's Manual b/manual/The User's Manual index 586464bb..eec21066 100644 --- a/manual/The User's Manual +++ b/manual/The User's Manual @@ -3,7 +3,7 @@ == The CHICKEN User's Manual <nowiki> -<img style="float:right; margin-left:1em;" src="/chicken-small.png" alt="Stylized picture of a chicken" /> +<img style="float:right; margin-left:1em;" src="http://wiki.call-cc.org/chicken-small.png" alt="Stylized picture of a chicken" /> </nowiki> This is the manual for CHICKEN Scheme, version 4.9.1 diff --git a/manual/Unit data-structures b/manual/Unit data-structures index de31b25a..ee5a6147 100644 --- a/manual/Unit data-structures +++ b/manual/Unit data-structures @@ -297,7 +297,7 @@ as the matching character in {{FROM}} is substituted. Substitutes elements of {{STRING}} according to {{SMAP}}. {{SMAP}} should be an association-list where each element of the list -is a pair of the form {{(MATCH \. REPLACEMENT)}}. Every occurrence of +is a pair of the form {{(MATCH . REPLACEMENT)}}. Every occurrence of the string {{MATCH}} in {{STRING}} will be replaced by the string {{REPLACEMENT}}: diff --git a/manual/Unit irregex b/manual/Unit irregex index b6bb45bb..7daff8c3 100644 --- a/manual/Unit irregex +++ b/manual/Unit irregex @@ -199,8 +199,15 @@ Examples: (irregex-replace "[aeiou]" "hello world" "*") => "h*llo world" (irregex-replace/all "[aeiou]" "hello world" "*") => "h*ll* w*rld" -</enscript> +(irregex-replace "(.)(.)" "ab" 2 1 "*") => "ba*" + +(irregex-replace "...bar" "xxfoobar" (lambda (m) + (string-reverse (irregex-match-substring m)))) => "xxraboof" + +(irregex-replace "(...)(bar)" "xxfoobar" 2 (lambda (m) + (string-reverse (irregex-match-substring m 1)))) => "xxbaroof" +</enscript> ===== irregex-split ===== irregex-extract diff --git a/manual/Unit library b/manual/Unit library index 61b13b4a..7e02f142 100644 --- a/manual/Unit library +++ b/manual/Unit library @@ -908,7 +908,7 @@ Returns {{#t}} if {{X}} is a promise returned by {{delay}}, or <procedure>(equal=? X y)</procedure> -Similar to the standard parocedure {{equal?}}, but compares numbers +Similar to the standard procedure {{equal?}}, but compares numbers using the {{=}} operator, so {{equal=?}} allows structural comparison in combination with comparison of numerical data by value. diff --git a/manual/Using the compiler b/manual/Using the compiler index 6270008d..a770e2fc 100644 --- a/manual/Using the compiler +++ b/manual/Using the compiler @@ -60,7 +60,7 @@ the source text should be read from standard input. ; -emit-type-file FILENAME : Write type-information for declarations of user-defined and globally visible variables to a file of the given name. The generated file is suitable for use with the {{-types}} option. -; -explicit-use : Disables automatic use of the units {{library, eval}} and {{extras}}. Use this option if compiling a library unit instead of an application unit. +; -explicit-use : Disables automatic use of the units {{library, eval}} and {{expand}}. Use this option if compiling a library unit instead of an application unit. ; -extend FILENAME : Loads a Scheme source file or compiled Scheme program (on systems that support it) before compilation commences. This feature can be used to extend the compiler. This option may be given multiple times. The file is also searched in the current include path and in the extension-repository.Trap