In article <335440D1.email@example.com>,
Graham Matthews <firstname.lastname@example.org> wrote:
>Charles Lin wrote:
>> If one had to choose a single type for everything, a string is a
>> pretty good choice. Why not a number? How would you represent a
>> string with a number? You can represent a number with a string.
>> Just put quotes around it.
>Oh come on -- if you have a a finite alphabet then there is a bijection
>between the natural numbers and strings over that finite alphabet. For
>example if you N symbols in your alphabet, A ..., then AA is represented
This is, of course, a long-established and deep theoretical result,
but I think for these purposes it's pretty much irrelevant, or trivially
true of most existing implementations already, depending on how you look
The real issue is not whether you can create a correspondence between
the natural numbers and anything you want, but whether you can do it
efficiently. It's just easier to use pointer-linked data structure
representations than to maintain such a mapping to the naturals in any
obvious and direct way.
Of course, most languages do maintain a mapping from language-level
objects such as strings and records---a string or record value is
represented as a pointer to the string or record, and that pointer
is represented as something like a virtual address (an integer offset
from the beginning of the address space), maybe tagged or whatever at
the implementation level, and usually abstracted into an "object reference"
at the language level, rather than being exposed as a raw address.
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (email@example.com)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and Scheme interpreters and compilers available via ftp from
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)