,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2026-09-12 15:19:31 ruv wrote: | referenceImplementation - Udate reference implementation for `ALSO` | see: https://forth-standard.org/standard/search/ALSO#contribution-448 `------------------------------------------ The original reference implementation does not handle the case where the search order is empty. ```forth : ALSO ( -- ) GET-ORDER DUP 0= IF -50 THROW THEN OVER SWAP 1+ SET-ORDER ; ``` NB: the search order overflow should be checked in `set-order`. See also: the section [16.4.1.2 Ambiguous conditions](https://forth-standard.org/standard/search#subsubsection.16.4.1.2), [Table 9.1](https://forth-standard.org/standard/exception#table:throw:~:text=search%2Dorder%20underflow), and contribution [#447](https://forth-standard.org/standard/search/ALSO#contribution-447). ,---------. | Replies | `---------´ ,------------------------------------------ | 2026-09-12 07:09:17 BerndPaysan replies: | proposal - New words: latest-name and latest-name-in | see: https://forth-standard.org/proposals/new-words-latest-name-and-latest-name-in#reply-1757 `------------------------------------------ If I have the case of a data type needs checking and throwing if it's not correct, I usually create a word that throws on error: ``` : ?nt ( nt|0 -- nt ) \ throws on nt=0 dup 0= -80 and throw ; ``` Then the cases where there needs to be a check can have that check, and it's a short word to insert, e.g. ``` : immediate ( -- ) immediate-mask latest-name ?nt >flags or! ; ``` ,------------------------------------------ | 2026-09-12 15:06:02 ruv replies: | requestClarification - What should happen when calling ALSO when the search order is empty? | see: https://forth-standard.org/standard/search/ALSO#reply-1758 `------------------------------------------ > I don't understand what would happen if the search order is empty. This is an implicit ambiguous condition: it should obviously have been declared, but was likely overlooked. The Table 9.1 contains a throw code `-50` [search-order underflow](https://forth-standard.org/standard/exception#table:throw:~:text=search%2Dorder%20underflow). ,------------------------------------------ | 2026-09-12 17:16:11 ruv replies: | proposal - New words: latest-name and latest-name-in | see: https://forth-standard.org/proposals/new-words-latest-name-and-latest-name-in#reply-1759 `------------------------------------------ > ```forth > : ?nt ( nt|0 -- nt ) \ throws on nt=0 > dup 0= -80 and throw ; > ``` In that case, what is the error message? Note that we already have `?found ( x1\0 -- x1 ^^ 0 -- never )`. > Then the cases where there needs to be a check can have that check, and it's a short word to insert, This approach is useful when you sometimes need to handle `0` locally, while in other cases you need to throw an exception. For `latest-name`, there is almost **no use cases** where you need to handle `0` locally (please, provide examples if you have). And in very rare cases where you need to handle `0` locally, I suggest to use another word. ----- To avoid similarity in names when the stack effect is not similar, I suggest to change the naming as follows: ``` last-name-in ( wid -- nt|0 ) \ It is needed as a basic API method last-name ( -- nt|0 ) \ It is very optional, since it is almost not needed in practice latest-name ( -- nt ) \ It is used in most practical use cases ``` Is it acceptable for you?