Req: (print exact words $Words)

It would be nice if there was a way to execute a predicate and collect output from the predicate and then print it out exactly. (print words $) makes everything lower case and (Print Words $) capitalizes each word.

Scenario: in TC, if a quip has a (nag $), it would be nice to prefix that output with a (beat $), but if no nag, no beat.

1 Like

Hi!

I’m wary of this, because it could easily lead to inefficient code. Dialog dictionary words are primarily designed to represent player input, and can sometimes also work as simple printable constants (e.g. when they are used to name actions). They are case insensitive, because player input is always converted to lower case anyway. But they aren’t intended for representing output text, and the runtime just isn’t designed for passing large chunks of text around.

I’m not saying that it would be impossible to add such a feature. One way would be to add special words: Just like (get key $) can return special words for e.g. the cursor keys, one could add special words for (space), (no space), (uppercase), and so on. These could be inserted into the list generated by (collect words), so that e.g. “Hello, XYZ” would come out as [<uppercase> hello , <uppercase> X <nospace> <uppercase> Y <nospace> <uppercase> Z]. And printing the special words could be made to reproduce the desired behaviour.

But besides the performance issue, there’s also the matter of side-effects. Suppose you have the following (contrived) code:

(narrate age of bob)
        (select)
                with youthful enthusiasm
        (or)
                in a jaded manner
        (or)
                , by now a mere shadow of his former self
        (stopping)

(beat #my-quip)
        Bob clears his throat (narrate age of bob).

(nag #my-quip)
        Well, what's your answer, inquires Bob (narrate age of bob).

If you first evaluate (nag $) and store the text in a variable, and then evaluate (beat $), then the output from “beat” describes an older Bob than the stored text.

Could you implement the desired functionality with closures instead, somehow? It would result in better performance, and preserve the relative order of output text and side-effects.

For the moment, the (nag $) is required to invoke the (beat $) if it likes, and maybe that’s for the best.