renamed generic object pointer to traditional void *self
[svn/Cll1h/.git] / cll1.txt
CommitLineData
04a13a6f 1THIS FILE IS OBSOLETE !!!
2
3
4
30628092 5
6C<<1: The Programming Language
7==============================
8
9Feedback: xchaos@arachne.cz
10Homepage: http://gpl.arachne.cz
11
12Copyright (G) 2004 Michael Polak, x@n.cz
13C<<1 is available under terms of GNU Lesser Public License (LGPL)
14This file is available under terms of GNU Free Documentation License
15
161. Introduction
17---------------
18
19There are various extensions and definitions of classical C language,
20for example object oriented "C++" and "Objective C", minimalistic C--,
21proprietary C# used by .Net project, etc. Many other modern languages
22
23C<<1 is designed to work as "stylesheet" for very classical ANSI C, and
24it was specificaly tested to work fine with GNU C Compiler gcc. There is
25no special C<<1 compiler or interpreter; instead, you are expected to
26include special header file called cll1.h the same way you would include
27let's say string or I/O library implemented in standard C library. Except
28that you don't need to link your executable with any special library,
29neither staticaly nor dynamicaly, and you don't have to configure your gcc
30or make to do so.
31
32#include <cll1.h>
33
34Or #include "cll1.h", if cll1.h is not installed in your /usr/include
35directory. That'it. No linking, no initialization, allocation, or so.
36
37C<<1 can be used for dummy, structured or object oriented programing,
38whatever method you prefere. C<<1 focuses mainly on adding new complex
39semantic structures into C, rather than inventing brand new syntax or class
40hieararchy, or providing set of pre-defined library functions. To allow
41that, most of C<<1 functions are implemented as macros for C preprocessor.
42
432. Getting started
44------------------
45
46#include <cll1.h>
47
48program
49{
50 puts("Hello World!");
51}
52
53Of course, int main(int argc,void **argv) can be still used. In fact,
54macro "program" doesn't do much more than that ! Following program prints
55all arguments:
56
57program
58{
59 char *ptr;
60
61 arguments
62 {
63 thisargument(ptr);
64 puts(ptr);
65 }
66 else
67 puts("Bleeeeh, no arguments supplied... :-(");
68}
69
70Well, don't be surprised with "else" after "arguments". This is not the
71last time in C<<1, when you will see C keywords somewhere you don't expect
72them. Of course, you would like to use it this way, I guess:
73
74program
75{
76 char *ptr;
77
78 arguments
79 {
80 argument("-?") printf("This is just help!\n");
81 else argument("-f") { nextargument(ptr) printf("Forced argument: %s\n",ptr); }
82 else { thisargument(ptr); printf("Simple argument: %s \n",ptr); }
83 }
84 else
85 puts("Bleeeeh, no arguments supplied... :-(");
86}
87
882. Where is my main() funciton ?!
89---------------------------------
90
91If you want to use int main(int argc,void **argv) { } instead of
92program { }, it's ok. Being fan of Basic and not Pascal, I don't
93like the program keyword at all. In fact, by avoiding "program" construct
94and using standard main() declaration, you would be still able to access
95most of C<<1 functionality, but for example not the arguments() structure
96mentioned above.
97
983. Ok, let's go on
99------------------
100
101This is some code to send e-mail using unix sendmail:
102(ok, nothing special, same as "echo .... | sendmail ....")
103
104program
105{
106 paste("From: me@here\nSubject: Here we go...\n\nblah blah blah")
107 system("/usr/sbin/sendmail someone@somewhere");
108}
109
110This program prints exactly 6th column of /etc/passwd file
111(ok, nothing special, same as "cut -f 6 -d : /etc/passwd")
112
113program
114{
115 char *ptr;
116 parse("/etc/passwd")
117 {
118 column(ptr,_,':',6);
119 if(ptr)puts(ptr);
120 }
121 done;
122}
123
124But next program prints 1st and 6th column of /etc/passwd.
125(What is equivalent in bash ?)
126
127program
128{
129 char *ptr;
130 int i;
131 parse("/etc/passwd")
132 {
133 columns(ptr,_,':',i) switch(i)
134 {
135 case 1: printf("%s...",ptr); break;
136 case 6: puts(ptr);
137 }
138 }
139 done;
140}
141
142
1434. Groups of C<<1 macros
144------------------------
145
146! - macro is available only when using "program" instead of "main()"
147
148I. Unconditional iterations - without else
149
150every
151iterate
152repeat !
153
154II. Conditional iterations - else can happen once
155
156find
157arguments !
158argument
159nextargument
160
161III. Conditional iterations - else can happen many times
162
163search
164valid_split
165valid_columns
166
167IV. Weird iterations (with something special)
168
169parse - [fail] - done
170
171V. Standalone sequences - they look like function calls, but they are not.
172
173insert
174append
175push
176remove
177sort
178shell
179paste
180column
181valid_column
182...
183
184VI. Well behaved seqences - can be used anywhere where functions can.
185
186create
187string
188goto_*
189prefix
190suffix
191...
192
1935. Forbidden namespace
194----------------------
195
196Variables starting with _ (underscored) followed by one or more capital
197characters (A-Z) are reserved as C<<1 private compile-time namespace.
198
1996. Compile time errors
200----------------------
201
202- parse error at end of input
203
204You probably forgot to close some macro which must be obligatory
205terminated by another macro - as "parse error" message suggests,
206it is likely to be error in macro "parse() { } [ fail ] { } done; "
207
208:-)
209
2107. We apologize for inconvenience
211---------------------------------
212
213This documentation file is unfortunately incomplete.
214HTML online documentation is comming soon ... sooner ... or later...
This page took 0.307865 seconds and 4 git commands to generate.