source: project/wiki/eggref/4/dollar @ 13592

Last change on this file since 13592 was 13592, checked in by Kon Lovett, 12 years ago

Save.

File size: 3.2 KB
Line 
1[[tags: egg]]
2
3== dollar
4
5[[toc:]]
6
7
8== Documentation
9
10A convenience macro for direct calls to foreign functions.
11
12''Note: this extension is only needed for CHICKEN versions 2.425 and higher''
13
14=== $
15
16<macro>($ [RETURNTYPE] NAME (TYPE ARGUMENT) ...)<macro>
17
18Invokes a C/C++ function by evaluating the arguments, performing the neccessary
19type-conversions for the foreign type-specifiers {{TYPE ...}} and calling
20{{NAME}} (which must be a symbol).
21
22If {{RETURNTYPE}} is given, then the result will be converted properly and
23returned, otherwise {{void}} is assumed.
24
25The type/argument lists may also be literal Scheme data or expressions of the
26form {{(quote LITERAL)}} or {{(location ...)}} - in this case the arguments are
27converted according to the type of the literal or are treated as a
28{{c-pointer}}, respectively.
29
30Booleans, characters, numbers, strings, SRFI-4 number vectors and symbols are
31converted, all other data is passed as being of type {{scheme-object}}.
32
33Callbacks into Scheme are not allowed inside the invoked foreign code.
34
35This macro expands into one of the {{foreign-lambda*}}, {{foreign-code}} or
36{{foreign-value}} forms.
37
38
39== Usage
40
41<enscript language=scheme>
42(require-library dollar)
43(import dollar)
44</enscript>
45
46or
47
48<enscript language=scheme>
49(require-extension dollar)
50</enscript>
51
52or
53
54csc ... -extend dollar ...
55
56
57== Examples
58
59<enscript language=scheme>
60($ printf "%d times Hello, %s!\n" 1000 "world")
61
62(define f 99.2)
63(let-location ((double n))
64  (let ((f ($ double modf (double f) (location n))))
65    (cons n f) ) )
66<enscript language=scheme>
67
68
69== Notes
70
71
72== Requirements
73
74
75== Bugs and Limitations
76
77* 'csc ... -extend dollar ...' does not work as expected.
78
79
80== Author
81
82[[kon lovett]]
83
84
85== Version history
86
87; 1.0.0 : Chicken 4 release.
88
89
90== License
91
92 Copyright (c) 2000-2006, Felix L. Winkelmann
93 All rights reserved.
94
95 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
96 conditions are met:
97
98   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
99     disclaimer.
100   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
101     disclaimer in the documentation and/or other materials provided with the distribution.
102   Neither the name of the author nor the names of its contributors may be used to endorse or promote
103     products derived from this software without specific prior written permission.
104
105 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
106 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
107 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
108 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
110 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
111 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
112 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
113 POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.