Down 13.10.2007 02:56 - oppdatert 216 dager siden av Terje Pedersen Colon

Colon 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. {1 2 3 4} | out # liste
  2. {name: "Terje Pedersen" age: 31} | "key: @key val: @0" out # hash
  3. 1 5 to | out # generator
  4. "Hello World!" | "char: @0" out

Conditional

Word Description
? Execute block after if element on stack is true
: Else block
; End if
  1. # if
  2. 5 5 = ? "yes" out
  3. # if/else
  4. 3 5 > ? "greater" : "less" ; out
  5. # if/else if/else
  6. 3
  7. 5 < ? "less" out
  8. 5 > ? "greater" out
  9. : "equal" out
  10. # switch
  11. "a"
  12. "a" = ?
  13. "case a" out
  14. "b" = ?
  15. "case b" out
  16. # pattern matching
  17. {ok 5} {ok _} = ? "ok @tail" out
  18. {warning "This is a warning"} {warning _} = ? "warning: @tail" out
  19. {1 2} {x y} = ? "x=@x y=@y" out drop
Tilbaketråkk url: klikk her!
Stikkord: colon,prosjekt

Relevante innlegg/sider/lenker

0 tilbaketråkk: