Vocabularies in Retro

7 views
Skip to first unread message

Charles Childers

unread,
Aug 26, 2009, 2:29:12 PM8/26/09
to RETRO 10
A few people have asked me to add support for vocabularies, so I'd
like to get some input on a few things before I start coding.

1) syntax for creation

2) syntax for adding to list of active vocabularies

3) syntax for setting up a list of vocabularies

4) how many *active* vocabularies should be allowed

Any input here will be appreciated. Thanks in advance,

-- crc

Mat

unread,
Aug 28, 2009, 9:18:11 AM8/28/09
to RETRO 10
Hello,

after experimenting a bit, I think the option for hirarchical creation
of vocabularies is a good thing for namespace structuration but have
the disadvantage of added complexibility:

use assembler use disassembler see dump

works fine for example but what if I need to address a word not
visible in the current namespace ? -

use assembler use disassembler see ins <- not possible because ins was
defined as a word from the previous vocabulary.

So we need at minimum a word for joining vocabulary entries or adding
a second namespace into the search list.

All this lead to a huge increase of complexibility both in
implementation and usage !

For my implementation that's not a problem because all vocabularies
inside a vocabulary schare there definitions. This way it is possible
to create common word assemblages. It has however the disadvantage of
no support for hirarchical structuration.

So the best thing would be if the two concepts can be merged in some
way:

1.) Syntax for creation:
assemblage: name (for assemblies)
voc: name (for vocabularies)

2.) Syntax for adding to list of active vocabularies
none needed, assemblages can be joind simply be
defining them inside a assemblage.

3.) Syntax for setting up a list of vocabularies
for this a word class should be created so the
vocabulary name itself would set the context.

4.) how many *active* vocabularies should be allowed
At minimum two.

Ciao,
Mat.

On 26 Aug., 20:29, Charles Childers <charles.child...@gmail.com>
wrote:

Charles Childers

unread,
Aug 28, 2009, 2:36:12 PM8/28/09
to retr...@googlegroups.com
Addressing a word outside the current vocabulary is easily doable with
an extra word:

{{
variable current
: get-voc ' current ! ;
: set-current current @ @ last ! ;
: update last @ current @ ! [ ' ok 2 + compile ] ;

: parent current @ last @ ;
: child last ! current ! ;
: action ' execute ;
---reveal---
: use get-voc set-current ;
: voc create last @ , ;
: in parent push push use action pop pop child ;

voc core use core
' update is ok
}}

Then:

voc test-0
use test-0
: a 1 . ;

voc test-1
use test-1
: a 2 . ;

use test-0

: b 2 . ;

in test-1 a
a

use test-1
in test-0 b

use core

in test-0 in test-1 a

-- crc

Charles Childers

unread,
Aug 28, 2009, 6:26:15 PM8/28/09
to retr...@googlegroups.com
This is an updated version of the last prototype with significantly
more stability and a new feature to make accessing nested vocabularies
cleaner.

Words Provided:

voc
Description: Create a vocabulary.
Usage:
voc name

use
Description: Make a vocabulary active
Usage:
use name

use|
Description: Activate a vocabulary, allows easier access to nested vocabularies.
Usage:
use| parent child0 child1 ... |
Notes: In this example, child1 is a vocabulary within child0 which is
itself inside parent.

in
Description: Access a word inside another vocabulary
Usage:
in name word
Notes: "in" can be nested:
in parent in child word


Now for the actual code:

{{
variable current
: activate current @ @ last ! ;


: update last @ current @ ! [ ' ok 2 + compile ] ;

: save current @ last @ ;
: restore last ! current ! ;
: action ' 0; which @ d->class @ with-class ;
---reveal---
: use ' 0; current ! activate ;
: use| repeat ' 0; current ! activate again ;


: voc create last @ , ;

macro: in save push push use action pop pop restore ;

voc core use core
' update is ok
}}


This has the original Retro wordset accessible via "use core".

Note for those using low-level hooks:
This code replaces the original prompt ("ok") with a new one that
keeps the vocabulary up to date with changes to the dictionary. You
would need to account for this if your code replaces "ok" with
something else.

-- crc

Mat

unread,
Aug 31, 2009, 12:36:22 PM8/31/09
to RETRO 10
Hello,

Another idea:

Wordlists should group definations so why not implement a subset of
set theory -

: test ... ;
: test1 ... ;

...

union set: test <- create a set from all members of earlier defined
words (core set) and the new ones.

~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
| test | | |
| ~~~~~~~~~~~~ | | core |
| | core | | | |
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

test set <- all words from set test are now accessible.

~~~~~~~~~~~~~~~~~~~~~~
| test + core |
~~~~~~~~~~~~~~~~~~~~~~

complement .<- the active set is the complement of all members in test
and the implicite set of all ealier defined words (only all words of
the core set are again visible).

~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
| test | | |
| ~~~~~~~~~~~~ | | core |
| | core | | | |
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

: test2 ... ;
: test3 ... ;

union set: test1

~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
| test1 | | test | | |
| ~~~~~~~~~~~~ | | ~~~~~~~~~~~~ | | core |
| | core | | | | core | | | |
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

test set join <- all words from set test1 are merged into set

~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
| test + test1 | | |
| ~~~~~~~~~~~~ | | core |
| | core | | | |
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

test1 set

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| test + test 1 + core |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: test4 .... ;
: test5 .... ; extend <- add some words to the current set.

I see one advantage: Sets can be freely combined without the need to
handle wordlist hirarchies.

-Mat

On 29 Aug., 00:26, Charles Childers <charles.child...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages