Ergebnis für URL: http://www.gnu.org/software/guile/manual/html_node/Definition.html #[1]Top [2]Concept Index [3]Table of Contents [4]About Data [5]Values and
Variables
Previous: [6]Values and Variables, Up: [7]Data Types, Values and Variables
[[8]Contents][[9]Index]
____________________________________________________________________________
3.1.3 Defining and Setting Variables
To define a new variable, you use Scheme's define syntax like this:
(define variable-name value)
This makes a new variable called variable-name and stores value in it as the
variable's initial value. For example:
;; Make a variable `x' with initial numeric value 1.
(define x 1)
;; Make a variable `organization' with an initial string value.
(define organization "Free Software Foundation")
(In Scheme, a semicolon marks the beginning of a comment that continues until the
end of the line. So the lines beginning ;; are comments.)
Changing the value of an already existing variable is very similar, except that
define is replaced by the Scheme syntax set!, like this:
(set! variable-name new-value)
Remember that variables do not have fixed types, so new-value may have a
completely different type from whatever was previously stored in the location
named by variable-name. Both of the following examples are therefore correct.
;; Change the value of `x' to 5.
(set! x 5)
;; Change the value of `organization' to the FSF's street number.
(set! organization 545)
In these examples, value and new-value are literal numeric or string values. In
general, however, value and new-value can be any Scheme expression. Even though
we have not yet covered the forms that Scheme expressions can take (see
[10]Expressions and Evaluation), you can probably guess what the following set!
example does...
(set! x (+ x 1))
(Note: this is not a complete description of define and set!, because we need to
introduce some other aspects of Scheme before the missing pieces can be filled
in. If, however, you are already familiar with the structure of Scheme, you may
like to read about those missing pieces immediately by jumping ahead to the
following references.
* [11]Lambda Alternatives, to read about an alternative form of the define
syntax that can be used when defining new procedures.
* [12]Procedures with Setters, to read about an alternative form of the set!
syntax that helps with changing a single value in the depths of a compound
data structure.)
* See [13]Internal definitions, to read about using define other than at top
level in a Scheme program, including a discussion of when it works to use
define rather than set! to change the value of an existing variable.
____________________________________________________________________________
Previous: [14]Values and Variables, Up: [15]Data Types, Values and Variables
[[16]Contents][[17]Index]
References
1. http://www.gnu.org/software/guile/manual/html_node/index.html
2. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
3. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
4. http://www.gnu.org/software/guile/manual/html_node/About-Data.html
5. http://www.gnu.org/software/guile/manual/html_node/Values-and-Variables.html
6. http://www.gnu.org/software/guile/manual/html_node/Values-and-Variables.html
7. http://www.gnu.org/software/guile/manual/html_node/About-Data.html
8. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
9. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
10. http://www.gnu.org/software/guile/manual/html_node/About-Expressions.html
11. http://www.gnu.org/software/guile/manual/html_node/Lambda-Alternatives.html
12. http://www.gnu.org/software/guile/manual/html_node/Procedures-with-Setters.html
13. http://www.gnu.org/software/guile/manual/html_node/Internal-Definitions.html
14. http://www.gnu.org/software/guile/manual/html_node/Values-and-Variables.html
15. http://www.gnu.org/software/guile/manual/html_node/About-Data.html
16. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
17. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
Usage: http://www.kk-software.de/kklynxview/get/URL
e.g. http://www.kk-software.de/kklynxview/get/http://www.kk-software.de
Errormessages are in German, sorry ;-)