Retro is a concatenative, stack based language with roots in Forth.

It is designed to be small, easily learned, and easily modified to meet specific needs, it has been developed and refined through continual use by a small community over the last decade.


This blog is written in Retro and has served as my primary means of posting things concerning Retro since 2010. The core code for Corpse is included in the Retro releases and can be freely studied and deployed.

The most recent posts are shown below. You can also view a list of all posts.

Post 195 of 215

2012-07-07

Memory Access in Parable

The segmented memory in Parable makes some things more complex. This can be demonstrated by building a string from characters:

In Retro:

  here  'h , 'e , 'l , 'l , 'o , 0 ,

In Parable:

  memory.request
  $h over #0 memory.store
  $e over #1 memory.store
  $l over #2 memory.store
  $l over #3 memory.store
  $o over #4 memory.store
  #0 over #5 memory.store
  :string

To help reduce this, I've added several functions for treating a slice as a Retro-style heap. Currently the above can become:

  memory.request dup heap.setSlice
  $h heap.store/advance
  $e heap.store/advance
  $l heap.store/advance
  $l heap.store/advance
  $o heap.store/advance
  #0 heap.store/advance
  :string

If we rename heap.store/advance to . then the code becomes only moderately longer than in Retro.

  memory.request dup heap.setSlice
  $h , $e , $l , $l , $o , #0 ,
  :string

I'll be fleshing out the heap namespace with other functions in the near future to help it come closer to being useful for building arrays and other data structures.


View comments for this article