16.6.2.0715 ALSO SEARCH EXT

( -- )

Transform the search order consisting of widn, ... wid2, wid1 (where wid1 is searched first) into widn, ... wid2, wid1, wid1. An ambiguous condition exists if there are too many word lists in the search order.

Implementation:

: ALSO ( -- )
   GET-ORDER OVER SWAP 1+ SET-ORDER
;

Testing:

T{ ALSO GET-ORDER ONLY -> get-orderlist OVER SWAP 1+ }T

ContributeContributions

AtHavatar of AtH [70] ALSO without VOCABULARY Request for clarification2018-09-18 12:51:27

Can someone provide an example, how to add a wordlist in the search order with the help of ALSO ?

In good old times we wrote VOCABULARY EDITOR … ONLY FORTH ALSO EDITOR

Now, when VOCABULARY is not in the Standard, we write WORDLIST CONSTANT EDITOR and what? GET-ORDER EDITOR SWAP 1+ SET-ORDER doesn’t require ALSO

AntonErtlavatar of AntonErtl

ALSO works with FORTH EDITOR ASSEMBLER. I guess they wanted to provide ALSO even if they could not define VOCABULARY because of diverging practice. Do we have common practice for VOCABULARY now? If so, it could be standardized.

JennyBrienavatar of JennyBrien

I don't think vocabularies give anything wordlists don't, and wordlists are more flexible. Why have two stes of words to do the same thing?

The most common name I've seen for the wordlist equivalent of ALSO is +ORDER ( wid -- add to search order) with -ORDER as a synonym of PREVIOUS.

If you really need VOCABULARY you can define it:

: VOCABULARY CREATE WORDLIST , DOES> -ORDER @ +ORDER ;

AtHavatar of AtH

Vocabularies provide laconism. Wordlists clarify one implementation level under vocabularies.

FORTH is still in the standard. ASSEMBLER and EDITOR are common practice and also vocabularies. It’s a good manner to provide portable and established way to create such words, as FORTH . If not, we can remove the word ALSO as well.

Your reference implementation for VOCABULARY is a good start. I tweaked it to use only standard words: : VOCABULARY CREATE WORDLIST , DOES> @ >R GET-ORDER SWAP DROP R> SWAP SET-ORDER ;

ruvavatar of ruv

I prefer to make VOCABULARY, FORTH, and ALSO words obsolescent. In place of these words the new words to work with wordlists in modular manner should be designed and added.

AntonErtlavatar of AntonErtl

Vocabularies are common practice, and have no technical problems. That's a good reason to keep them standardized. If you, like me, prefer to use wordlists, do it. Standardized vocabularies do not impede this.

AtHavatar of AtH

Is it consensus, that status of ALSO, VOCABULARY and FORTH should be the same (all in the standard or all not in the standard)? ALSO without VOCABULARY makes little sense in the Standard Program. They all use the same undocumented construction (vocabulary). I suggest to legalize all three (and document vocabulary) or get rid of them.

I’m now in the process of migration from old nested vocabulary system to ALSO/ONLY and context of several WORDLISTs.

When I learned, that VOCABULARY is no longer in Standard, I tried to get rid of this word. My understanding now is that if I implement ALSO/ONLY, VOCABULARY should stay. Semantics will change a little, because VOCABULARY now aren’t based on each other. Also vocabulary execution affects now the search list in more predictable and standard way. If this change is important, a new word should be introduced. VOC or DICTIONARY could be used as the new name.

Reply New Version