rename references to old names in doc
FossilOrigin-Name: 0b0cd20ed69027a7d9b5f2d905d7b9e033e2976208385652d888da35432a4482
This commit is contained in:
parent
73493f92f4
commit
ed89e0bde8
5 changed files with 30 additions and 30 deletions
|
@ -128,7 +128,7 @@ To create new functions, you use the compiler. This is generally
|
|||
started by using the `:` (pronounced *colon*) prefix. A simple
|
||||
example:
|
||||
|
||||
:foo #1 #2 + putn ;
|
||||
:foo #1 #2 + n:put ;
|
||||
|
||||
Breaking this apart:
|
||||
|
||||
|
@ -157,13 +157,13 @@ calls the corresponding class handler. The class handler for
|
|||
normal words calls the code at the address if interpreting, or
|
||||
compiles a call to it if the `Compiler` is active.
|
||||
|
||||
putn
|
||||
n:put
|
||||
|
||||
The process is repeated for `putn`.
|
||||
The process is repeated for `n:put`.
|
||||
|
||||
;
|
||||
|
||||
The last word has a slight difference. Like `+` and `putn`, this
|
||||
The last word has a slight difference. Like `+` and `n:put`, this
|
||||
is a word, not a prefixed token. But the class handler for this
|
||||
one always calls the associated code. In this case, `;` is the
|
||||
word which ends a definition and turns off the `Compiler`.
|
||||
|
@ -178,15 +178,15 @@ difficult to explain, so let's take a quick look at how it works:
|
|||
>>> A ?
|
||||
#1000 'A var<n>
|
||||
:scale (x-y) A fetch * ;
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 3000
|
||||
#100 A store
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 300
|
||||
#5 'A var<n>
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 300
|
||||
A fetch putn
|
||||
A fetch n:put
|
||||
>>> 5
|
||||
|
||||
Output is marked with **>>>**.
|
||||
|
@ -321,9 +321,9 @@ Comparisons
|
|||
-----------
|
||||
Strings can be compared using `s:eq?`:
|
||||
|
||||
'test_1 'test_2 s:eq? putn
|
||||
'test_1 'test_2 s:eq? n:put
|
||||
>>> 0
|
||||
'test_3 'test_3 s:eq? putn
|
||||
'test_3 'test_3 s:eq? n:put
|
||||
>>> -1
|
||||
|
||||
The comparisons are case sensitive.
|
||||
|
|
|
@ -7,15 +7,15 @@ take a quick look at how it works:
|
|||
~~~
|
||||
#1000 'a var<n>
|
||||
:scale (x-y) @a * ;
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 3000
|
||||
#100 !a
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 300
|
||||
#5 'a var<n>
|
||||
#3 scale putn
|
||||
#3 scale n:put
|
||||
>>> 300
|
||||
@a putn
|
||||
@a n:put
|
||||
>>> 5
|
||||
~~~
|
||||
|
||||
|
|
|
@ -6,26 +6,26 @@ Displaying Things
|
|||
Numbers
|
||||
=======
|
||||
|
||||
#100 putn
|
||||
#100 n:put
|
||||
|
||||
|
||||
Characters
|
||||
==========
|
||||
|
||||
$a putc
|
||||
$a c:put
|
||||
|
||||
|
||||
Strings
|
||||
=======
|
||||
|
||||
'hello,_world puts
|
||||
'hello,_world s:put
|
||||
|
||||
|
||||
Mixed
|
||||
=====
|
||||
|
||||
#1 #2 #3 '%n_-_%n_=_%n\n s:format puts
|
||||
'Charles' 'Hello_%s\n s:format puts
|
||||
#1 #2 #3 '%n_-_%n_=_%n\n s:format s:put
|
||||
'Charles' 'Hello_%s\n s:format s:put
|
||||
|
||||
|
||||
Conditionals
|
||||
|
@ -134,13 +134,13 @@ Counted
|
|||
=======
|
||||
|
||||
(simple,_no_index_on_stack)
|
||||
#10 [ $a putc ] times
|
||||
#10 [ $a c:put ] times
|
||||
|
||||
|
||||
Conditional
|
||||
===========
|
||||
|
||||
#10 [ n:dec dup putn dup n:-zero? ] while
|
||||
#10 [ n:dec dup n:put dup n:-zero? ] while
|
||||
|
||||
|
||||
Math
|
||||
|
|
|
@ -25,22 +25,22 @@ flag is `TRUE`:
|
|||
|
||||
~~~
|
||||
#1 #2 eq?
|
||||
[ 'True! puts ] if
|
||||
[ 'True! s:put ] if
|
||||
~~~
|
||||
|
||||
Or if it's `FALSE`:
|
||||
|
||||
~~~
|
||||
#1 #2 eq?
|
||||
[ 'Not_true! puts ] -if
|
||||
[ 'Not_true! s:put ] -if
|
||||
~~~
|
||||
|
||||
There's also a `choose` combinator:
|
||||
|
||||
~~~
|
||||
#1 #2 eq?
|
||||
[ 'True! puts ]
|
||||
[ 'Not_true! puts ] choose
|
||||
[ 'True! s:put ]
|
||||
[ 'Not_true! s:put ] choose
|
||||
~~~
|
||||
|
||||
RETRO also uses combinators for loops:
|
||||
|
@ -48,7 +48,7 @@ RETRO also uses combinators for loops:
|
|||
A counted loop takes a count and a quote:
|
||||
|
||||
~~~
|
||||
#0 #100 [ dup putn sp n:inc ] times
|
||||
#0 #100 [ dup n:put sp n:inc ] times
|
||||
~~~
|
||||
|
||||
You can also loop while a quote returns a flag of `TRUE`:
|
||||
|
@ -68,7 +68,7 @@ instance, many structures provide a `for-each` combinator which can be run
|
|||
once for each item in the structure. E.g., with a string:
|
||||
|
||||
~~~
|
||||
'Hello [ putc ] s:for-each
|
||||
'Hello [ c:put ] s:for-each
|
||||
~~~
|
||||
|
||||
Moving further, combinators are also used for filters and operations on
|
||||
|
|
|
@ -31,7 +31,7 @@ Example:
|
|||
|
||||
(Define_some_words)
|
||||
:hello (-)
|
||||
'Hello_World! puts nl ;
|
||||
'Hello_World! s:put nl ;
|
||||
|
||||
:n:square (n-m)
|
||||
dup * ;
|
||||
|
@ -44,9 +44,9 @@ hello
|
|||
$a (this_is_the_ASCII_'a')
|
||||
|
||||
'Use_underscores_in_place_of_spaces_in_strings
|
||||
&puts call
|
||||
&s:put call
|
||||
|
||||
'Foo var
|
||||
#100 !Foo
|
||||
@Foo putn
|
||||
@Foo n:put
|
||||
~~~
|
||||
|
|
Loading…
Reference in a new issue