Skip to content

Instantly share code, notes, and snippets.

: :: here ] ;
: nv-key ['] key 2 + compile ; immediate ( unvectored key )
:: nv-key dup 27 =if nv-key dup . nip ;then ; is key
Compiler macros are often used to lay down code in the calling word. You'll see something like:
: foo ['] + compile ['] . compile ; immediate
This is fine, but sometimes you need to deal with other macros:
: bar 1 literal, 2 literal, ['] foo execute ; immediate
This approach has one problem: keeping track of what words need to be compiled and which need to be called. Plus, with Retro's use of word classes, you may have other words that are handled in other ways.
Compiler macros are often used to lay down code in the calling word. You'll see something like:
: foo ['] + compile ['] . compile ; immediate
This is fine, but sometimes you need to deal with other macros:
: bar 1 literal, 2 literal, ['] foo execute ; immediate
This approach has one problem: keeping track of what words need to be compiled and which need to be called. Plus, with Retro's use of word classes, you may have other words that are handled in other ways.
: stub create 0 , 0 , 9 , ['] .word last @ d->class ! ;
stub foo
last @ d->class @ .
: stubs for stub next ;
stub cursor
4 stubs up down left right
: :: ( -a ) here ] ;
: stub create 0 , 0 , 9 , ['] .word last @ d->class ! ;
: stubs for stub next ;
stub cursor
stub scan-for-esc
4 stubs up down left right
: default: ( "- )
{{
: (`)
dup 0 !if literal, which @ d->class @ compile ;then
drop tib >number literal, ['] .data compile ;
---reveal---
: '' ; immediate
: `` repeat ' dup ['] '' =if drop ;then (`) again ; immediate
}}
: :: ( -a ) here ] ;
@lsparrish
lsparrish / gist:250116
Created December 6, 2009 07:28
Refactored pad
variable addr
::: Power function
: pow ( bp-n )
over here ! ::: Store the base for later use.
1 - 0; ::: Subtract 1 from the power and exit if the result is 0.
for here @ * next ; ::: Fetch the base and multiply it by the number.
::: Get the top value from the address stack.
: r ( -n ) ` pop ` dup ` push ; immediate
: append ( $$-$ )
swap
here push
here over getLength dup allot copy
here over getLength dup allot copy
0 , pop ;
: paren-wrap s" (" swap append s" )" append ;
: append ( $$-$ )
swap
here push
here over getLength dup allot copy
here over getLength dup allot copy
0 , pop ;
: paren-wrap s" (" swap append s" )" append ;
@lsparrish
lsparrish / REM.rst
Created December 20, 2009 19:08 — forked from crcx/REM.rst

Retro Editor for Mortals

Author: Charles Childers
Version: 2009.12.20

REM User's Guide