source: project/wiki/friendly-chicken @ 39490

Last change on this file since 39490 was 39490, checked in by Mario Domenech Goulart, 5 months ago

/friendly-chicken: adapt to C5

File size: 3.7 KB
Line 
1== Friendly CHICKEN
2
3If you're a CHICKEN beginner, you come from another language or a different scheme implementation, there are a few things you might be wondering about, when you're first exposed to CHICKEN. This little tutorial shall help you to lower the barriers and highlight some little pitfalls so that your time with CHICKEN is more fun from the very beginning.
4
5For a general introduction to CHICKEN, see [[man/5/Getting started|Getting started]].
6
7=== UTF-8
8
9CHICKEN's string procedures generally operate on byte-strings. That means they are not aware of encodings such as UTF-8.
10The following csi transcript shows this:
11
12<enscript highlight="bash">
13CHICKEN
14(c) 2008-2020, The CHICKEN Team
15(c) 2000-2007, Felix L. Winkelmann
16Version 5.2.0 (rev 317468e4)
17linux-unix-gnu-x86-64 [ 64bit dload ptables ]
18
19Type ,? for help.
20#;1> (string-length "λ")
212
22#;2>
23</enscript>
24
25As you see {{string-length}} on the string containing the unicode-character returns 2 rather than 1.
26To fix this you need to install and use [[/egg/utf8|the utf8 egg]] ({{chicken-install utf8}}).
27
28See the transcript with {{utf8}} loaded:
29
30<enscript highlight="bash">
31CHICKEN
32(c) 2008-2020, The CHICKEN Team
33(c) 2000-2007, Felix L. Winkelmann
34Version 5.2.0 (rev 317468e4)
35linux-unix-gnu-x86-64 [ 64bit dload ptables ]
36
37Type ,? for help.
38#;1> (import utf8)
39; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.import.so ...
40
41Note: re-importing already imported identifier: string-length
42
43Note: re-importing already imported identifier: string-ref
44
45Note: re-importing already imported identifier: string-set!
46
47Note: re-importing already imported identifier: make-string
48
49Note: re-importing already imported identifier: string
50
51Note: re-importing already imported identifier: substring
52
53Note: re-importing already imported identifier: string->list
54
55Note: re-importing already imported identifier: list->string
56
57Note: re-importing already imported identifier: string-fill!
58
59Note: re-importing already imported identifier: write-char
60
61Note: re-importing already imported identifier: read-char
62
63Note: re-importing already imported identifier: display
64
65Note: re-importing already imported identifier: print
66
67Note: re-importing already imported identifier: print*
68; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.so ...
69; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/regex.so ...
70; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8-lolevel.so ...
71#;2> (string-length "λ")
721
73</enscript>
74
75Nevermind the notes -- they are just an indication that procedures from the {{utf8}} egg are redefining the procedures from the {{scheme}} module.
76
77
78=== Load useful libraries and units in csi automatically
79
80If you find yourself using these libraries alot you might want to have {{csi}} load them whenever you start it up.
81This can easily be done by adding them to your {{$HOME/.csirc}}.
82
83A sample {{.csirc}} might look like this:
84
85<enscript highlight="scheme">
86(import utf8 srfi-1 srfi-13)
87</enscript>
88
89Note that you have to install {{utf8}}, {{srfi-1}} and {{srfi-13}} via {{chicken-install}}.
90
91
92=== Other useful eggs and units for real world tasks
93There are some other units and eggs that you might find helpful to solve real world problems with CHICKEN.
94The following lists a few of them:
95
96
97==== Eggs
98* [[/egg/utf8|UTF8]] - Make string procedures utf8 aware
99* [[/egg/srfi-1|SRFI-1]] - List procedures
100* [[/egg/srfi-13|SRFI-13]] - String procedures
101* [[/egg/srfi-69|SRFI-69]] - Hashtables
102
103==== Units
104(You don't need to chicken-install these)
105* [[/manual/Module (chicken irregex)|irregex]] - Regular expressions
106
107
108=== Happy Hacking
109
110I hope this little guide helps you to start your CHICKEN journey without too many surprises.
111Have fun hacking ...
Note: See TracBrowser for help on using the repository browser.