1717
1818- Stack is used to organize calls to words, NOT as a data structure.
1919- No package manager.
20- All libraries of the language are part of the Factor monorepo.
21- Along with docs.
20+ - All libraries of the language are part of the Factor monorepo.
21+ - Along with docs.
22+ - all values are truthy, except "f"
2223
2324- vocabularies: named set of words (me: libraries)
2425
26+ ** types
27+ https://docs.factorcode.org/content/article-tuple-examples.html
28+ |-----------+---+----------------------------------------------------|
29+ | boolean | ? | t f |
30+ | lists | | { 0 1 2 3 } |
31+ | hashs | | H{ { "Perl" "L. Wall" } { "Factor" "S. Pestov" } } |
32+ | bytearray | | B{ 1 14 18 23 } |
33+ | range | | [0,b] |
34+ |-----------+---+----------------------------------------------------|
2535** quotations
2636
2737#+begin_src factor
2838 [ "Hello, World" print ]
2939#+end_src
30- - are unammed blocks of code
40+
41+ - https://docs.factorcode.org/content/vocab-fry.html
42+ - is a block of code
43+ - can be pushed to the stack as a value
3144- you can ~call~ it
45+ |-------+----------------------|
46+ | call | a f -- (f a) |
47+ | dip | a b f -- (f a) b |
48+ | keep | a b f -- (f a b) b |
49+ | bi | a f g -- (f a) (g a) |
50+ | bi@ | a b f -- (f a) (f b) |
51+ | curry | a f -- [f a] |
52+ |-------+----------------------|
53+
54+ ** conditionals
3255
56+ #+begin_src factor
57+ 0 [] when ! when* leaves test value on stack, WHEN TRUE
58+ 0 [] unless
59+ 2 ["Two is true" .] ["Invalid" .] if
60+ #+end_src
61+
62+ ** loops
63+ |--------------+----------+------------|
64+ | | | <c> |
65+ | times | n f | f0..fn |
66+ | each-integer | n f | f(0)..f(n) |
67+ | each | list f | |
68+ | map | list f | list' |
69+ | reduce | list n f | n' |
70+ | accumulate | list n f | list' n' |
71+ | replicate | | |
72+ | produce | n pred f | list |
73+ | while | n pred f | n' |
74+ |--------------+----------+------------|
3375** words
3476
3577#+begin_src factor
4284
4385- new words are defined at parse time
4486 - stack effects are used, error is reported if wrong
87+ - modifiers: inline, recursive
4588
4689- ~combinators~ are words that take quotations
4790 - eg: if, map
4891
49- - those that manipulate the stack are called *shuffle words*
92+ - *parsing words*
93+ - commonly used to defining literals (eg: list, hash, bytearray)
94+ - interact with the parser
95+ - defined with *SYNTAX:*
96+ - eg: [ ] : ;
97+
98+ *** shuffling words
99+ - manipulate the stack
100+ |-------+-------+---------|
101+ | dup | x | x x |
102+ | drop | x | |
103+ | swap | x y | y x |
104+ | over | x y | x y x |
105+ | dupd | x y | x x y |
106+ | swapd | x y z | y x z |
107+ | nip | x y | y |
108+ | rot | x y z | y z x |
109+ | -rot | x y z | z x y |
110+ | 2dup | x y | x y x y |
111+ |-------+-------+---------|
50112
51113* Standalone Executables
52114
@@ -62,12 +124,13 @@ https://concatenative.org/wiki/view/Factor/Deployment
62124 * libstdc++.so.6
63125- does NOT support "stripping" with "strip"
64126- single core compiler (?
65- - ~8min in compile "tetris" example
66- ~3Mb
127+ - 35s in compile "hello world", 1.6Mb
128+ - 8min in compile "tetris", ~3Mb
67129
68130** hello world
69131
70- - Run in a directory above ~./hello/~
132+ - Binary at ./hello/hello
133+ - Run in a directory above ~./hello/~, in ~./~
71134 #+begin_src sh
72135 $ factor -roots=. -e='USING: namespaces tools.deploy tools.deploy.config ; "." deploy-directory set "hello" deploy'
73136 # 40 seconds
116179* libraries/vocabularies
117180
118181- x11 example https://github.com/letoh/hello-x11-factor
182+ - json
183+ - https://docs.factorcode.org/content/article-json.html
184+ - https://docs.factorcode.org/content/vocab-json.html
119185- all
120186 https://docs.factorcode.org/content/article-vocab-index.html
121187 https://docs.factorcode.org/content/article-handbook-library-reference.html
188+ - kernel https://docs.factorcode.org/content/vocab-kernel.html
122189- ui examples https://docs.factorcode.org/content/article-ui.html
123190- raylib https://github.com/ArnautDaniel/raylib-factor
124191 - https://github.com/ArnautDaniel/raylib-factor/blob/master/examples/piggy/piggy.factor
128195 https://concatenative.org/wiki/view/Factor/Furnace
129196 https://docs.factorcode.org/content/vocab-furnace.html
130197
198+ * tools
199+
200+ - editor: emacs https://github.com/factor/fuel
201+
131202* codebases
132203
133204- ed(itor) clone https://github.com/zphixon/fed
0 commit comments