Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
You can edit this page using
wiki syntax
for markup.
Article contents:
== CHICKEN for Racket programmers Warning: This is very much a work in progress! [[toc:]] === Running scripts The first line in a script file meant to be run by the Racket interpreter can either contain a path pointing to the interpreter on your system directly (e.g., {{#!/usr/bin/racket}}) or use the {{env}} utility to find it: <enscript> #!/usr/bin/env racket #lang racket </enscript> As Racket is a family of languages rather than just one language, Racket scripts require a second line declaring the language used in the script that follows. In Chicken, such a declaration is not needed. At the same time, using {{env}} as shown above is not a viable solution for Chicken scripts because the Chicken Scheme interpreter ({{csi}}) requires the {{-s}} option in order to run in script mode rather than in REPL mode. And it seems as if, currently, only GNU {{env}} provides a way to run commands with additional arguments form a shebang line. So, the most straightforward way to get your Chicken scripts to run is simply using the actual path to the Chicken Scheme interpreter on your system. This can easily be found by running {{command -v csi}} in a non-interactive POSIX-compatible shell: <enscript> $ sh -c 'command -v csi' </enscript> Running the shell non-interactively bypasses any existing shell command aliases, which is the desired behavior here. On a Debian system, the above command returns {{/usr/bin/csi}}. On NetBSD, you get {{/usr/pkg/bin/csi}}. So, to create a runnable Chicken script on the latter, the first line in the file has to be this: <enscript> #!/usr/pkg/bin/csi -s </enscript> Should you need your Chicken scripts to be portable, there are also ways to achieve that without using {{env}}. See [[writing portable scripts|Writing portable scripts]]. === Procedures ==== Optional arguments ==== Named parameters === String handling ==== Splitting strings ==== Regular expressions ==== {{case}} Racket's {{case}} expression deviates from the R6RS and R7RS standards in that it uses {{equal?}} instead of {{eqv?}} to compare data. Because of that, Racket's {{case}} can also work with strings: <enscript> (let ([str "egg"]) (case str (("egg") #t) (else #f))) ; => #t </enscript> As Chicken's {{case}} uses {{eqv?}}, as defined in the Scheme standard, the same is not possible in Chicken. For simple cases, converting the key into a symbol and then using symbols inside {{case}} provides an easy solution to this problem: <enscript> (let ([str "egg"]) (case (string->symbol str) ((egg) #t) (else #f))) ; => #t </enscript> That said, {{cond}} – or {{match}} from the ''matchable'' egg – provide more reliable and more comfortable solutions for handling strings, especially those containing special characters such as whitespace, non-printables, the vertical bar ({{|}}), etc. See the [[man/6/Module (scheme base)#symbols|section on symbols]] in the Chicken Manual for details.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 3 to 10?