16.6.1.1595 FORTH-WORDLIST SEARCH

( -- wid )

Return wid, the identifier of the word list that includes all standard words provided by the implementation. This word list is initially the compilation word list and is part of the initial search order.

Testing:

T{ FORTH-WORDLIST wid1 ! -> }T

ContributeContributions

LSchmidtavatar of LSchmidt [229] inconsistent namingRequest for clarification2022-03-18 14:04:40

I'm not really happy with naming FORTH-WORDLIST FORTH-WORDLIST, for the reason that naming it that way sets the pattern for naming other words which are meant to produce wids according the same pattern: <name-of-wordlist>-WORDLIST.
Following and applying that pattern would then suggest that SEARCH-WORDLIST produces the wid of the wordlist SEARCH, which is clearly not the case.
It is therefore my opinion that either SEARCH-WORDLIST or FORTH-WORDLIST is an inconsistent misnomer, with the name FORTH-WORDLIST introducing a resemblance of hungarian notation (making the "type" of the underlying object part of the name). To distinguish FORTH-WORDLIST (producing the wid) from FORTH (using wid), I think that FORTHID or FORTH-ID (that it's a wordlist id, I assume user knows, and so the "w" for wordlist doesn't really need to suffer hungarisation) may be a better choice, also in view of naming other words intended to produce wordlist ids.

ruvavatar of ruv

that SEARCH-WORDLIST produces the wid of the wordlist SEARCH

Yes, it can give such an impression on the first glance. With only one correction: FORTH is not a word list, but a vocabulary (a definition that changes the search order, another such a word is ASSEMBLER).

In Forth naming culture, a part of speech is very significant. The naming patterns {verb}-xxx and {noun}-xxx are different. And you cannot expect a similar behavior for the words having names by different patterns.

In this case, search is used in names as a verb (see meaning), but forth is used as a noun. And "search-wordlist" means to search in the given wordlist, but "forth-wordlist" means just the word list identifier of the "forth".

Usually, "verb"-words do something and may have side effects, but "singular-noun"-words don't have side effects (beyond stacks) and just return something. Although, vocabularies (that are nouns) is an exception to the rule due to historical reasons (it's an inconsistency, of course).

Many inconsistencies in naming, and even very strange names (like >IN) have place just due to historical accidents, since they were introduced when nobody things about consistency, and then they were supported for backward compatibility. But still, some of them were introduced lately (like BUFFER:), unfortunately.

As you can see, there are many cases of more significant inconsistencies in naming than this case (that's quite lite).

What we can do in this regard in general, is to find better names and introduce them as synonyms, and then, after some long time, obsolete the old names.

LSchmidtavatar of LSchmidt

yes, search can be used as verb - but also as noun.

AntonErtlavatar of AntonErtl

SEARCH-WORDLIST has other problems, too: 1) It returns an xt, but some systems have words with two xts (one for interpretation semantics and one for compilation semantics). 2) It has a stack effect with a variable number of result cells.

FIND-NAME-IN fixes these problems (as well as not having "-WORDLIST" in the name) and has been accepted for standardization.

However, there has been no proposal for making SEARCH-WORDLIST obsolescent. I have my doubts that the problems (including the naming inconsistency) will be considered reason enough for such a hypothetical proposal to be accepted, but I may be wrong (the benefit side of keeping it standardized is also slim IMO), so if you feel strongly about it, you could try making such a proposal. If such a proposal succeeds, SEARCH-WORDLIST will be marked as obsolescent in the next standard, and (unless some motion to keep it around) will be removed from the standard in the standard after that. Of course, many systems will still implement it for backwards compatibility.

In general, while consistent naming is an argument when a word is proposed for standardization, it is trumped by backwards compatibility and established practice. I don't remember anyone even proposing to rename an already standardized word; and of course therefore also no successful proposals.

I am closing this because it looks more like a pre-proposal to me than a request for clarification. If you want to pursue this further, please make a proposal.

Closed
Reply New Version

lmravatar of lmr [322] at head of ORDER?Comment2023-12-21 17:21:11

FORTH-WORDLIST's spec only says that it must be part of the initial search order (i.e. not necessarily on top). However, WORDS lists all words in the word-list on top of the search order. It seems that placing FORTH at the head (and, for example, possible extension word-lists behind it) is the only reasonable choice. There may be other places that mandate FORTH to be on top, I'm not sure.

Reply New Version