Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
The answer is indicated on the page for f. Specifically, "[t]he f object is the singleton false value, the only object that is not true." In contrast, t is defined simply as SINGLETON: t where SING...
Answer
#1: Initial revision
The answer is indicated on the page for [`f`](https://docs.factorcode.org/content/word-f,syntax.html). Specifically, "[t]he `f` object is the singleton false value, the only object that is not true." In contrast, [`t`](https://docs.factorcode.org/content/word-t,syntax.html) is defined simply as `SINGLETON: t` where [`SINGLETON:`](https://docs.factorcode.org/content/word-SINGLETON__colon__%2Csyntax.html) defines a class and thus a class word which is the sole instance of that class (i.e. itself). For the purposes of logical comparisons, there is absolutely nothing special about `t`. Literally any object (other than `f`) could be used instead. As the docs say, `t` is just a "canonical" choice. `f`, on the other hand, is uniquely special. `f` couldn't be defined the same way as `t`, i.e. as a `SINGLETON:` because then `f` and its class word would be the same thing, but the class word of `f` should be a perfectly normal object, and thus behave as true, and only its instance should behave as false. Ultimately, the `f` object (as opposed to the `f` parsing word) is deeply wired into the Factor implementation. `t` gets some mild special handling by the implementation because the implementation needs to sometimes return `t` from the C++ implementation code. But it is not *defined* by the C++ code, while the `f` object is. To be clear, `f` being a parsing word has nothing to do with the behavior you saw with `random`. The reason `f random` works is because `f` is an instance of an [`immutable-sequence`](https://docs.factorcode.org/content/word-immutable-sequence%2Csequences.html) and thus a [`sequence`](https://docs.factorcode.org/content/word-sequence%2Csequences.html) for which [`random`](https://docs.factorcode.org/content/word-random,random.html) is defined. `t` is not. Factor, like many languages, especially dynamically typed languages with "generalized" booleans, fails to distinguish between "no result" and "a valid result that happens to be `f`". In other words, `{ } random` and `{ f } random` both return `f` but for different reasons. `f random` is behaving more like the former as `f` behaves like an empty sequence.