(Higher level thread procedures): Replace some
[bpt/guile.git] / doc / scheme-procedures.texi
CommitLineData
38a93523
NJ
1@page
2@node Procedures and Macros
3@chapter Procedures and Macros
4
5@menu
6* Lambda:: Basic procedure creation using lambda.
7* Optional Arguments:: Handling keyword, optional and rest arguments.
8* Procedure Properties:: Procedure properties and metainformation.
9* Procedures with Setters:: Procedures with setters.
10* Macros:: Macros.
11@end menu
12
13
14@node Lambda
15@section Lambda: Basic Procedure Creation
16
17
18@node Optional Arguments
19@section Optional Arguments
20
21
22@node Procedure Properties
23@section Procedure Properties and Metainformation
24
25@c docstring begin (texi-doc-string "guile" "procedure-properties")
26@deffn primitive procedure-properties proc
27Return @var{obj}'s property list.
28@end deffn
29
30@c docstring begin (texi-doc-string "guile" "procedure-property")
31@deffn primitive procedure-property p k
32Return the property of @var{obj} with name @var{key}.
33@end deffn
34
35@c docstring begin (texi-doc-string "guile" "set-procedure-properties!")
36@deffn primitive set-procedure-properties! proc new_val
37Set @var{obj}'s property list to @var{alist}.
38@end deffn
39
40@c docstring begin (texi-doc-string "guile" "set-procedure-property!")
41@deffn primitive set-procedure-property! p k v
42In @var{obj}'s property list, set the property named @var{key} to
43@var{value}.
44@end deffn
45
46@c docstring begin (texi-doc-string "guile" "procedure-documentation")
47@deffn primitive procedure-documentation proc
48Return the documentation string associated with @code{proc}. By
49convention, if a procedure contains more than one expression and the
50first expression is a string constant, that string is assumed to contain
51documentation for that procedure.
52@end deffn
53
54@c docstring begin (texi-doc-string "guile" "closure?")
55@deffn primitive closure? obj
56Return @code{#t} if @var{obj} is a closure.
57@end deffn
58
fcaedf99 59@r5index procedure?
38a93523
NJ
60@c docstring begin (texi-doc-string "guile" "procedure?")
61@deffn primitive procedure? obj
62Return @code{#t} if @var{obj} is a procedure.
63@end deffn
64
65@c docstring begin (texi-doc-string "guile" "thunk?")
66@deffn primitive thunk? obj
67Return @code{#t} if @var{obj} is a thunk.
68@end deffn
69
70@c docstring begin (texi-doc-string "guile" "set-source-properties!")
71@deffn primitive set-source-properties! obj plist
72Install the association list @var{plist} as the source property
73list for @var{obj}.
74@end deffn
75
76@c docstring begin (texi-doc-string "guile" "set-source-property!")
77@deffn primitive set-source-property! obj key datum
78Set the source property of object @var{obj}, which is specified by
79@var{key} to @var{datum}. Normally, the key will be a symbol.
80@end deffn
81
82@c docstring begin (texi-doc-string "guile" "source-properties")
83@deffn primitive source-properties obj
84Return the source property association list of @var{obj}.
85@end deffn
86
87@c docstring begin (texi-doc-string "guile" "source-property")
88
89@deffn primitive source-property obj key
90Return the source property specified by @var{key} from
91@var{obj}'s source property list.
92@end deffn
93
94
95@node Procedures with Setters
96@section Procedures with Setters
97
98@c docstring begin (texi-doc-string "guile" "make-procedure-with-setter")
99@deffn primitive make-procedure-with-setter procedure setter
100Create a new procedure which behaves like @var{procedure}, but
101with the associated setter @var{setter}.
102@end deffn
103
104@c docstring begin (texi-doc-string "guile" "procedure-with-setter?")
105@deffn primitive procedure-with-setter? obj
106Return @code{#t} if @var{obj} is a procedure with an
107associated setter procedure.
108@end deffn
109
110@c docstring begin (texi-doc-string "guile" "procedure")
111@deffn primitive procedure proc
112Return the procedure of @var{proc}, which must be either a
113procedure with setter, or an operator struct.
114@end deffn
115
116@c docstring begin (texi-doc-string "guile" "setter")
117@deffn primitive setter proc
118@end deffn
119
120
121@node Macros
122@section Macros
123
124[FIXME: This needs some more text on the difference between procedures,
125macros and memoizing macros. Also, any definitions listed here should
126be double-checked by someone who knows what's going on. Ask Mikael, Jim
127or Aubrey for help. -twp]
128
129@c docstring begin (texi-doc-string "guile" "procedure->syntax")
130@deffn primitive procedure->syntax code
ae9f3a15
MG
131Return a @dfn{macro} which, when a symbol defined to this value
132appears as the first symbol in an expression, returns the
133result of applying @var{code} to the expression and the
134environment.
38a93523
NJ
135@end deffn
136
137@c docstring begin (texi-doc-string "guile" "procedure->macro")
138@deffn primitive procedure->macro code
ae9f3a15
MG
139Return a @dfn{macro} which, when a symbol defined to this value
140appears as the first symbol in an expression, evaluates the
141result of applying @var{code} to the expression and the
142environment. The value returned from @var{code} which has been
143passed to @code{procedure->memoizing-macro} replaces the form
144passed to @var{code}. For example:
145@lisp
38a93523
NJ
146(define trace
147 (procedure->macro
148 (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))
149
150(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})).
ae9f3a15 151@end lisp
38a93523
NJ
152@end deffn
153
154@c docstring begin (texi-doc-string "guile" "procedure->memoizing-macro")
155@deffn primitive procedure->memoizing-macro code
ae9f3a15
MG
156Return a @dfn{macro} which, when a symbol defined to this value
157appears as the first symbol in an expression, evaluates the
158result of applying @var{proc} to the expression and the
159environment. The value returned from @var{proc} which has been
160passed to @code{procedure->memoizing-macro} replaces the form
161passed to @var{proc}. For example:
162@lisp
38a93523
NJ
163(define trace
164 (procedure->macro
165 (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))
166
167(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})).
ae9f3a15 168@end lisp
38a93523
NJ
169@end deffn
170
171@c docstring begin (texi-doc-string "guile" "macro?")
172@deffn primitive macro? obj
173Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a
174syntax transformer.
175@end deffn
176
38a93523
NJ
177@c docstring begin (texi-doc-string "guile" "macro-type")
178@deffn primitive macro-type m
ae9f3a15
MG
179Return one of the symbols @code{syntax}, @code{macro} or
180@code{macro!}, depending on whether @var{m} is a syntax
181tranformer, a regular macro, or a memoizing macro,
182respectively. If @var{m} is not a macro, @code{#f} is
183returned.
38a93523
NJ
184@end deffn
185
186@c docstring begin (texi-doc-string "guile" "macro-name")
187@deffn primitive macro-name m
188Return the name of the macro @var{m}.
189@end deffn
190
191@c docstring begin (texi-doc-string "guile" "macro-transformer")
192@deffn primitive macro-transformer m
193Return the transformer of the macro @var{m}.
194@end deffn
195
196@c docstring begin (texi-doc-string "guile" "cons-source")
197@deffn primitive cons-source xorig x y
198Create and return a new pair whose car and cdr are @var{x} and @var{y}.
199Any source properties associated with @var{xorig} are also associated
200with the new pair.
201@end deffn
202
203
204@c Local Variables:
205@c TeX-master: "guile.texi"
206@c End: