Charles Childers

blog | parable | retro | ios apps | fountain pens


Parable has a single, global dictionary which requires unique names for each function. This is ok, but it's sometimes useful to have finer control over things.

The first tool is a lexical scope, allowing for internal factors to be hidden. This is pretty simple:

[ 'a' 'b' 'c' ] {
    [ '_A' '_B' ] ::
    [ "n-" !_A ] 'a' :
    [ "n-" !_B ] 'b' :
    [ "nn-n" a b @A @B + ] 'c' :

When the closing } is encountered, Parable hides everything except for the names in the initial quotation.

This is really handy, but sometimes it's useful to have even more control. Perhaps we'd like to group a bunch of functions, and selectively make them visible or hidden. This requires something more: a system of vocabularies.

In 2016.03 this will be added to Parable. I'm still working on the syntax, but for now it's like this:

"Group a bunch of math functions into a vocabulary named math"
[ 'sin'  'tan'  'cos'  'asin'  'atan'  'acos' \
  'atan2'  'log'  'log10'  'log<n>' \
  'floor'  'min'  'max' \
] 'math' vocab

After vocab creates the vocabulary the names are hidden from the dictionary. They can be exposed or hidden using with and without:

&math with

"do something using the math functions"

&math without

Going a tiny bit further, it's also useful to create a vocabulary for a lexically scoped area. This is doable by extending the syntax a little:

[ 'a' 'b' 'c' ] 'foo' {
    [ '_A' '_B' ] ::
    [ "n-" !_A ] 'a' :
    [ "n-" !_B ] 'b' :
    [ "nn-n" a b @A @B + ] 'c' :

By providing a name and using }} instead of } a new vocabulary will be created with the exposed functions and the specified name.

There may be some changes to the syntax involved, but think the overall functionality will be a useful addition going forward.