strong/weak typing and pointers

Michael Hobbs mike at hobbshouse.org
Thu Nov 4 23:20:03 EST 2004


Steven Bethard <steven.bethard at gmail.com> wrote:
> The reason for this is that at any given time in OCaml, the sequence of bits is
> only interpretable as *one* of the two types, never both.  If you have a good
> example of using a union (in C probably, since OCaml wouldn't let you do this I
> don't think) where you want to treat a given sequence of bytes as both types *at
> once*, that would be great!

I've come up with the perfect example for you. However, it is from
the days when memory was scarce and programmers were allowed to use
any programming language they wanted, so long as it was assembly.

To conserve as much memory as possible, some programmers would use
machine code that was loaded into memory as their integer constants.
Here is an excerpt from The Story of Mel:
(http://www.catb.org/~esr/jargon/html/story-of-mel.html)

   Since Mel knew the numerical value
   of every operation code,
   and assigned his own drum addresses,
   every instruction he wrote could also be considered
   a numerical constant.
   He could pick up an earlier "add" instruction, say,
   and multiply by it,
   if it had the right numeric value.
   His code was not easy for someone else to modify.




More information about the Python-list mailing list