Re: Strings, Was: profile results for new UT_* implementations?


Subject: Re: Strings, Was: profile results for new UT_* implementations?
From: Dom Lachowicz (dominicl@seas.upenn.edu)
Date: Wed Jun 20 2001 - 11:07:49 CDT


I'd just like to clear the table here, and silence the critics and people in the
peanut gallery -

A string is a block of memory. A block of memory is not a string. There is an
important difference, and it has to do with semantics, rules, and expecations.
Consider the following two (true) statements:

A tree is a collection of atoms.
A collection of atoms is not necessarily a tree.

What makes a tree more than a collection of atoms? The definition of a tree
contains other things (made of wood, tall, has a brown trunk, green leaves, has
a root system, etc...) You can do certain things with trees that you can't do
with a collection of atoms (climb, cut down, burn, pluck fruit, etc...)

So then there are strings. Sure, strings are blocks of contiguous memory. Is
that all they are? Not on your life. You can perform certain operations on
strings (strcmp, toupper, tolower, concat, append) that aren't applicable to
blocks of memory in general. The semantics of a string is what makes it more
than just a block of memory. If you dispute this, you've been spending too many
Saturday nights in a dark room with only an assembler to keep you company.

For another example, groups of pixels are not buttons. Buttons are groups of
pixels, however, *plus* some added meaning and semantic rules. Buttons can be
pressed, checked, have states, greyed out, etc... They enforce some rules on top
of their pixel foundation.

Semantics are important in everyday life, and extremely important in
programming. Classes, structs, and OOP help us make these distinctions. It is
important to make distinctions between objects, and to clearly and carefully
define what their roles are to be.

Dom
apparently Aaron's intro to CSE teacher



This archive was generated by hypermail 2b25 : Wed Jun 20 2001 - 11:08:08 CDT