Skip to content

Instantly share code, notes, and snippets.

View crcx's full-sized avatar

Charles Childers crcx

View GitHub Profile
@crcx
crcx / backtick.rst
Created December 2, 2009 00:19 — forked from lsparrish/On the use of ` (back tick) in macros
Commentary on the use of ` in compiler macros

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:

@crcx
crcx / Commentary on creating stubs
Created December 2, 2009 03:04 — forked from lsparrish/gist:246886
Commentary on the creation and use of stubs
It's sometimes useful to be able to create an empty stub which will be pointed to a real definition later.
The simple solution is just to do:
: foo ;
This creates a new defintion ("foo"), with no runtime action. In Retro all colon definitions can be revectored, so this is all that is strictly required. It does have a downside with regard to readability. We can address this by defining a new word specifically to create stubs.
: stub ( "- ) create 0 , 0 , 9 , ['] .word last @ d->class ! ;
@crcx
crcx / later.rst
Created December 13, 2009 14:56
On the use of later

One of the more interesting flow control words in Retro is later. This is a word that returns control to the caller, then regains control when the caller is finished.

A simple example:

: test ( - ) 1 . later 2 . ;
: b ( - ) test 3 . ;

Run b, and you should see:

@crcx
crcx / code_style.rst
Created December 22, 2009 14:40
Code Style in Retro

Code Style in Retro

Author: Charles Childers
Version: 2009.12.22

Choosing Names

This is probably the most important. I'll just say:

@crcx
crcx / stack_comments.rst
Created January 1, 2010 17:45
Notes on stack comments in Retro

Reading Stack Comments

Stack comments in Retro are a compact form, using short codes in place of actual words. These codes are listed in the next section.

A typical comment for a word that takes two arguments and leaves one will look like:

@crcx
crcx / legal_stuff.rst
Created January 2, 2010 16:19
Notes on the legal status of Retro
@crcx
crcx / Vocabularies in Retro.rst
Created September 12, 2010 13:45
Notes on the Creation and Use of Vocabularies in Retro

Overview

In 10.7 (and beyond) the vocabulary system in Retro has been significantly altered. Prior releases provided nestable, collapsible subsets of the global dictionary. The new approach differs by:

  • no nesting
  • each vocabulary is a separate dictionary list
  • user controllable search order

Creating a Vocabulary

@crcx
crcx / locals.md
Last active December 10, 2015 00:58
Working implementation of local variables in Parable

Locals in Parable

We'll leverage slices. We track a single LOCALS pointing to the current slice for locals.

'LOCALS' variable
'( - )\nVariable; holds a pointer to the current set of local variables' 'LOCALS' describe

Functions will get wrapped in a localize combinator. This needs to save and restore the prior LOCALS. dip makes this easy:

[ &LOCALS @ [ memory.request &LOCALS ! invoke &LOCALS @ memory.release ] dip &LOCALS ! ] 'localize' define

@jsomers
jsomers / websters-kindle.mdown
Created May 19, 2014 01:42
How to make the Webster's 1913 your default Kindle dictionary

How to make the Webster's 1913 your default Kindle dictionary

  1. Download a Kindle-compatible version of the dictionary here. Unzip the .rar archive.

  2. Get the "Send to Kindle" program on your computer. Here's the link for the Mac.

  3. Right-click your recently downloaded (unzipped) dictionary file, and click the "Send to Kindle" menu item. It will arrive on your Kindle shortly.

  4. Once the dictionary has arrived, go to your settings -- on my newish paperwhite, it's at Home > Settings > Device Options > Language and Dictionaries > Dictionaries > English. Choose the Webster's 1913.

@mbillingr
mbillingr / pyrx.py
Last active April 23, 2023 05:58
Implementation of a minimal Forth interpreter/compiler on top of Python 3.5.
""" pyrx
Implementation of a minimal Forth interpreter/compiler on top of Python 3.6.
It is based on Rx [1] and should eventually support Retro [2].
Facts & Features:
- New words are compiled to Python bytecode (subroutine threading model).
- Dynamically typed: the only data type is the Python object.
- Literals are evaluated as Python expressions.
- The data stack is a global Python list.