Re: [Inform] Difference between "


Fri, 24 Nov 1995 21:23:18 -0500

"Sam Hulick" <shulick@kiwi.ucs.indiana.edu> writes:
> You know, I'll bet the " vs. ' is one of the toughest things to grasp in
> Inform. What is the real difference between:
>
> ...
> adjective "red" "big",
>
> and
>
> ...
> adjective 'red' 'big',
>
> I do know that dictionary words suck because you can't print them.
> What's the purpose, then?

Strings suck because you can't compare them easily. To compare two
strings, you need a loop which goes through and compares each byte
until a difference is found. But dictionary words are guaranteed to
each be represented by a different number, so you can compare them
with a single opcode.

It's simply the case that in text games, you have long strings that
you want to print, and short strings that you want to compare. There's
almost no overlap between the two sets. So it's efficient to have two
distinct data types. When you *do* want to print and compare the same
string, you need two copies, but that happens rarely enough that it's
not a big deal. (Compare that to the number of comparisons that happen
during a single command parse -- every word of the input to every verb
or every word in the names of every object in scope, possibly several
times.)

--Z

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."