~vdupras/duskos

ref: f68c6b8222cfe8a02d2f5192c54492bba7674a44 duskos/fs/doc/code.txt -rw-r--r-- 2.3 KiB
f68c6b82Virgil Dupras Move ufields from lib/struct to bootlo, as "field" a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Code conventions

## Patterns in code

@ means "fetch". Its presence in a word indicate that we fetch a value from
somewhere.

! means "store", the opposite of "fetch".

, means "write", that is, storing a value to "here" and increment here by that
value's width.

Those symbols above are sometimes accompanied by letters such as "c" (character)
or "w" (word), which means that instead of being 4 bytes wide (the default
width everywhere), it's 1 or 2 bytes wide.

' means "address of".

. means "print".

_ means "anonymous definitions" that are meant to be used locally and once.

_ as a prefix indicates a private word that is meant to be only used in the
context of the local unit.

? at the beginning of the word means "maybe we'll do it maybe we won't". For
example, "?dup" is meant as "maybe dup".

? at the end of a word indicate a yes/no answer. For example, "ws?" means "is
it a whitespace?".

# means "assert", meaning that an abort will take place in case of failure. For
example, "findpath#" means "try to find specified path and abort if not found".

^ means "opposite order". For now, it's only used in "-^" as a shortcut to
"swap -". Maybe we'll drop this...

[] indicates a range. For example, "[]=" means "compare ranges for equality".

[ as a suffix indicates the beginning of a special interpretation of words. For
example, "foo scratch[" overrides the default scratchpad until "]scratch" is
reached.

] as a prefix indicates the end of a special interpretation loop.

( as a suffix indicates the beginning of a buffer. For example, "in(" is the
address of the first char of the input buffer in sys/rdln.

) as a prefix indicates the end of a buffer, exclusively. For example, ")in c@"
is an out- of bounds fetch. ")in 1- c@" fetches the last char of the buffer.

> has ambiguous meaning. It's generally meant as "movement" or
"transformation". ">r" means "move element from PS to RS" and "[]>str" means
"transform a range into a string".

(words), that is, words inside parens, are "false words", that is, words that
you aren't expected to call directly, but rather to compile in a special
context. For example, calling "(?br)" makes no sense. "(?br)" is compiled by
"if".

& means "create doer" and is given to "does words" compilers. For example,
"42 &+" means "create an adder with a 42 constant".