13.10.2007 02:56
- oppdatert 222 dager siden av Terje Pedersen
ColonColon is a new stack-oriented programming language with focus on making GUI-applications for ARM based gadgets.
Use of signs
A list of which chars used before or after Colon words and the description of them.| Char | Description |
|---|---|
| name: | definition of words |
| nameX | repeat the word X times, ie. dup3 tail2 |
| :name | pop from stack and store in name word (a ->) |
| !name | dup :name (a -> a) |
| ¤name or ¤{...} | create a new concurrent process, pid on stack (-> pid) |
| ”@X @name” {@X @name} | pop position X from stack, @0 = first, @name call name use answer from stack, insert into string or block |
| +name | name + :name |
Numbers
| Type | Description | Example |
|---|---|---|
| integer | xxxx | 1 5 -7 0 |
| float | xx.xx | 0.0 5.23 -23.12 |
| hex | 0xxxxh | 0ah 052h 0fah |
| binary | 0xxxxb | 01111b 011011b |
| octal | 0xxxxo | 07o |
Comparing
| Char | Description | Example | On stack |
|---|---|---|---|
| > | større enn | 10 5 > | 10 true |
| < | mindre enn | 10 5 < | 10 false |
| ? | ulik | 10 5 ? | 10 true |
| = | lik | 10 5 = | 10 false |
Math
| Char | Description | Example | On stack |
|---|---|---|---|
| + | addisjon | 10 5 + | 15 |
| - | subtraksjon | 10 5 - | 5 |
| / | divisjon | 10 5 / | 2 |
| * | multiplikasjon | 10 5 * | 50 |
| % | modulo | 10 5 % | 0 |
Concurrency
| Word | Description | Example |
|---|---|---|
| receive | receive – wait for an incomming message and puts it on stack | receive out |
| send | msg pid send – sends a message to pid | “hello” pid send or 5 ¤{receive out} send |
Resources
| Word | Resource | Description |
|---|---|---|
| open | dcolon | “dcolon://192.168.0.2:7777/echo” open |
| open | file | “file://home/senikk/test.txt” open |
| open | mysql | “mysql://peter:abc123@localhost/my_db” open |
| open | web | “http://senikk.com” open |
| open | module | “mymodule.col” open |
Each
| Word | Description | Example |
|---|---|---|
| key | key – put key on stack | key out |
| yield | yield – stop execution keep the position, custom generators | yield |
| ;; | ;; – break each execution | ;; |
| to | a b to – to-generator from a to b | 1 5 to |
- {1 2 3 4} | out # liste
- {name: "Terje Pedersen" age: 31} | "key: @key val: @0" out # hash
- 1 5 to | out # generator
- "Hello World!" | "char: @0" out
Conditional
| Word | Description |
|---|---|
| ? | Execute block after if element on stack is true |
| : | Else block |
| ; | End if |
- # if
- 5 5 = ? "yes" out
- # if/else
- 3 5 > ? "greater" : "less" ; out
- # if/else if/else
- 3
- 5 < ? "less" out
- 5 > ? "greater" out
- : "equal" out
- # switch
- "a"
- "a" = ?
- "case a" out
- "b" = ?
- "case b" out
- # pattern matching
- {ok 5} {ok _} = ? "ok @tail" out
- {warning "This is a warning"} {warning _} = ? "warning: @tail" out
- {1 2} {x y} = ? "x=@x y=@y" out drop
Relevante innlegg/sider/lenker
| Innlegg: Sider: Lenker: | På forsiden: |



0 tilbaketråkk: