📄 chicken-setup.html
字号:
(compile hello2.scm) <I><FONT COLOR="#B22222">; compile `hello2'</FONT></I>(install-program 'hello2 <B><FONT COLOR="#BC8F8F">"hello2"</FONT></B>) <I><FONT COLOR="#B22222">; name of the extension and files to be installed</FONT></I></PRE><p>To use it, just run <tt>chicken-setup</tt> in the same directory:</p><pre>$ chicken-setup</pre><p>(Here we omit the extension name)</p><p>Now the program <tt>hello2</tt> will be installed in the same location as the other CHICKEN tools (like <tt>chicken</tt>, <tt>csi</tt>, etc.), which will normally be <tt>/usr/local/bin</tt>. Note that you need write-permissions for those locations and may have to run <tt>chicken-setup</tt> with administrative rights.</p><p>Uninstallation is just as easy:</p><pre>$ chicken-setup -uninstall hello2</pre><p><tt>chicken-setup</tt> provides a <tt>make</tt> macro, so build operations can be of arbitrary complexity. When running <tt>chicken-setup</tt> with an argument <tt>NAME</tt>, for which no associated file <tt>NAME.setup</tt>, <tt>NAME.egg</tt> or <tt>NAME.scm</tt> exists will ask you to download the extension via HTTP from the default URL <a href="http://www.call-with-current-continuation.org/eggs" class="external">http://www.call-with-current-continuation.org/eggs</a>. You can use the <tt>-host</tt> option to specify an alternative source location. Extensions that are required to compile and/or use the requested extension are downloaded and installed automatically.</p><p>If the given extension name contains a path prefix and the <tt>-host</tt> option is given, then <tt>chicken-setup</tt> can also download and install eggs from an arbitrary HTTP server. Alternatively you can pass a full URL (including the <tt>http://</tt> prefix. Note that no dependency checks are done when downloading eggs directly with the URL syntax.</p><p>Finally a somewhat more complex example: We want to package a syntax extension with additional support code that is to be loaded at run-time of any Scheme code that uses that extension. We create a <em>glass</em> lambda, a procedure with free variables that can be manipulated from outside:</p><PRE><I><FONT COLOR="#B22222">;;;; glass.scm</FONT></I>(define-macro (glass-lambda llist vars . body) <I><FONT COLOR="#B22222">;; Low-level macros are fun!</FONT></I> (<B><FONT COLOR="#A020F0">let</FONT></B> ([lvar (gensym)] [svar (gensym)] [x (gensym)] [y (gensym)] [yn (gensym)] ) `(<B><FONT COLOR="#A020F0">let</FONT></B> ,(map (<B><FONT COLOR="#A020F0">lambda</FONT></B> (v) (list v #f)) vars) (<B><FONT COLOR="#A020F0">define</FONT></B> (,svar ,x . ,y) (<B><FONT COLOR="#A020F0">let*</FONT></B> ([,yn (pair? ,y)] [,y (<B><FONT COLOR="#A020F0">and</FONT></B> ,yn (car ,y))] ) (<B><FONT COLOR="#A020F0">case</FONT></B> ,x ,@(map (<B><FONT COLOR="#A020F0">lambda</FONT></B> (v) `([,v] (<B><FONT COLOR="#A020F0">if</FONT></B> ,yn (<B><FONT COLOR="#A020F0">set!</FONT></B> ,v ,y) ,v) ) ) vars) (<B><FONT COLOR="#A020F0">else</FONT></B> (error <B><FONT COLOR="#BC8F8F">"variable not found"</FONT></B> ,x)) ) ) ) (<B><FONT COLOR="#A020F0">define</FONT></B> ,lvar (<B><FONT COLOR="#A020F0">lambda</FONT></B> ,llist ,@body)) (extend-procedure ,lvar ,svar) ) ) )</PRE><p>Here some support code that needs to be loaded at runtime:</p><PRE><I><FONT COLOR="#B22222">;;;; glass-support.scm</FONT></I>(require-extension lolevel)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -