From -9068793065036640064
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,8d9af67f0c48e4ef
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,8d9af67f0c48e4ef
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-05-04 18:02:11 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!feed.news.qwest.net!namche.sun.com!sunnews1.Eng.Sun.COM!engnews1.eng.sun.com!taumet!clamage
From: Daniel Miller <daniel.miller@tellabs.com>
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: Unsignedness of size_t
Date: 5 May 2002 00:55:20 GMT
Organization: Tellabs
Lines: 165
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <3CD2B89C.2050404@tellabs.com>
References: <3CC7DB8F.52E75D62@bawi.org>
  <3ccd58e5$0$20934$4c41069e@reader1.ash.ops.us.uu.net>
  <44d2ad1a.0205011234.6bf2b421@posting.google.com>
NNTP-Posting-Host: taumet.eng.sun.com
X-NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: Fri, 03 May 2002 11:19:40 -0500
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPNPvF0HMCo9UcraBAQF+eQH/W/ib20DOs2beOMTwTWN3okqQcSsgJMOO
	Q5dSWWzp+e30ZdJ4FT1nECDYFca2JB4k2npjryOe+GvGogIHwnovxg==
	=uy0E
X-Approved-For-Group: francis.moderator@robinton.demon.co.uk comp.lang.c++.moderated
X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang)
Content-Length: 10175
Originator: clamage@taumet
Xref: archiver1.google.com comp.std.c++:11046 comp.lang.c++.moderated:42669


Vahan Margaryan wrote:

 > The logic that 'unsigned quantities should always be represented by
 > unsigned types' is, IMO, wrong. Saying 'I had -3 guests' is illogical,
 > but saying 'john was seated -3 guests to the right of mary' may make
 > perfect sense in a programming context. A quantity that counts guests
 > is unsigned, a quantity that offsets guests is signed. In a sense,
 > that's what negative numbers were invented for. I don't want to mix
 > unsigned guest counts with signed guest offsets, because I feel that
 > will lead to bugs. That's why to me, only signed guests are welcome...


    You are conflating several things which should not be conflated.  One
inappropriate conflation is conflating a unit of measure (guest) with the
quantity being measured (attendence) and again a unit of measure (chair) with
vector being measured (order-at-table).  Further you are conflating two
quantities being measured (attendence versus order-at-table) which is causing
your inappropriate desire to intermix negative-nonnegative integers with
nonnegative-only integers.  Quite honestly, the defect is in your thinking about
your design's model-of-reality, not in the existence/application of unsigned
integers into the solution-space.  (Furthermore as an aside, focusing an entire
model of reality solely on "guests" instead of "people" or "attendees" begets a
model of reality in which it is either impossible or awkward to describe the
hosts of the party, how many hosts were in attendence, and where the hosts were
seated.)

    If I were to ask "How many guests attended the party?", your desire to
intermix these separate quantities as negative-nonnegative/signed integers
implies that I should be able to expect (and meaningfully process) answers in
reply such as "7 guests in attendence plus 3 guests to the right of Mary" and "7
guests in attendence plus -2 guests to the right of Mary" where Mary is
obviously some basis for order-at-table vector within a system of coordinates
and somehow this order-at-table vector is somehow meaningful outside of its
coordinate system---i.e., meaningful in the absolute magnitude of guests in
attendence.  The absolute magnitude of guests in attendence in fundamentally
separate from a vector in an order-at-table coordinate system because the
one-dimensional one-directional nonnegative-only attendence ever-increasing
linear axis (without wrapping around) is fundamentally separate from the
one-dimensional two-directional negative-nonnegative order-at-table cyclical
axis where left of Mary eventually wraps back around to right of Mary.

    If I were to ask "Where is Fred to sit?", your desire to intermix these
separate quantities as negative-nonnegative/signed integers implies that I
should be able to expect (and meaningfully process) answers in reply such as "5
guests in attendence plus 2 guests to the right of Mary" and "5 guests in
attendence plus -1 guests to the right of Mary".  Again, this sets off so many
levels of red flags in the human brain that something is seriously
wrong/imagined/contrived/insane/incoherent within the model of reality.  If such
statements are incoherent in natural language, software designs should also
firmly avoid purporting such bizarre models of imagination as desirable models
of reality.

    If 3 people (a magnitude) are currently in attendence and two more people (a
magnitude) arrive, your desire to intermix these separate quantities as
negative-nonnegative/signed integers successfully implies that normal everyday
garden-variety arithmetic applies: 3 guests plus 2 guests equals 5 guests now in
attendence (still a magnitude).
    But if Fred sits -1 chairs to the right of Mary (a vector) whereas Bob sits 1
chair to the right of Mary (a vector), your desire to intermix these separate
quantities as negative-nonnegative/signed integers (applied naively) would
incorrectly answer questions such as "How many chairs/dining-table-positions are
there from Fred to  Bob, inclusive?" with incorrect arithmetic such as
    -1 guests (inappropriately treating vector as magnitude) plus 1 guest
(inappropriately treating vector as magnitude)
    = -1 guests + 1 guests
    = zero guests (an incorrectly-calculated magnitude).
Instead one must realize that each order-at-table is a vector whose  magnitude
(absolute value) must be taken to answer such questions:
    the number of chairs from Fred inclusively to Mary exclusively (the magnitude
of a vector) plus Bob's chair-offset from Mary (a magnitude of a vector) plus
Mary's chair (a magnitude)
    = the number of chairs in the set [Fred,Mary) plus the number of chairs in
the set [Bob,Mary) plus Mary's chair
    = |-1| + |1| + 1
    = 1 + 1 + 1
    = 3
which is the correct magnitude in answer to the question referring to vectors.
    Once again there is a drastic difference between the guests-in-attendence
quantity versus the order-at-table quantity.  In this case the difference isn't
arguably over in the English Department or Philosophy Department, but firmly in
the Mathematics Department: guests-in-attendence quantities use garden-variety
elementary-school natural-number arithmetic whereas order-at-table quantities
use an arithmetic of directed-vectors.  There is a fundamental
difference-in-type between guests-in-attendence and order-at-table.  Software
designs should overtly represent that obvious difference-in-type, not merely
with 1) overt admission of signed versus unsigned integers, but with 2) overt
admission of the frame-of-reference/coordinate-system as well as 3) overt
admission of units of measure as well as 4) overt admission of arithmetic system
to be used within that frame-of-reference as well as 5) overt admission of
conversion-system/arithmetic-system between frames-of-reference/coordinate-systems.

    The fallacy within "I want to intermix quantities measured in
negative-positive integers with quantities measured in nonnegative-only
integers" claims typically have less to do with the signedness and a whole lot
more to do with inappropriately intermixing numeric-only quantities which
measure drastically different non-intermixable concepts/types/classes (e.g., a
natural number of people in attendence versus a vector of seats in a
dining-table-layout cyclic coordinate system).  Throughout modern software
design, I strongly advocate an application of the KISS principle:
    1) keep classes, objects, and quantities firmly grounded in reality,
    2) describe classes, objects, and quantities as they are factually
expressed/observed in reality,
    3) describe classes, objects, and quantities in ways which read cleanly in a
natural language such as English.

    There is the time-honored example in software design:
    The farmer can milk the cow.
    The cow can demilk itself.
    The milk can decowify itself.

    The further one goes out on the limb so to speak with one's contrived
nonreality-based thinking, the more troubles one has in bailing out the
ever-burgeoning surreality.  This is seen since time began in the software
industry in that aging software designs eventually get to a point that they can
no longer be bailed out due to incongruence of their flawed model-of-reality to
the ever-more-intricate problems at hand in reality.  Moral of the story: do not
mix quantities in one's software model-of-reality which are not meant to be
mixed in reality and do not mix classes/objects/quantities/relationships in
one's software model-of-reality in ways which are not expressable/observable in
reality.  This moral of making software designs comply with the
how-to-model-reality makes it very rare to even contemplate intermixing
negative-nonnegative integers with nonnegative-only integers and then when their
worlds do touch, they are likely to touch in ways which are quite appropriate &
compatible without defect and without conflict between the signed versus
unsigned/modulus arithmetic systems.

    I highly encourage everyone to realize that the modeling of reality in
software, especially object-oriented/pattern-based software, is highly dependent
on the objectivist (i.e., object-oriented) philosophy of Ayn Rand whose writings
drive home this point of remaining firmly based in a repeatable (i.e.,
reusable), knowable, expressable, observable reality instead of highly-contrived
thinking.  The highly-contrived thinking is based more on an
inventive/projective imagination than on an receptive cognition of
expressable/observable reality.  This applies not only to the narrower topic of
unsigned versus signed integers, but throughout all
object-oriented/type-parameterized software design & architecture as well.

    As such, the presence of unsigned integers and an unsigned size_t is a
wonderful aspect of C's & C++'s ability to model reality.  I strongly affirm the
other pro-unsigned postings along these threads.  I also successfully use
unsigned integers throughout my designs without defect.  Any problem with
intermixing negative-nonnegative/signed integers with nonnegative-only/unsigned
integers is a problem with the design's overly-contrived model of imagination,
not with the semantics of unsigned and not with the presence of unsigned.

    A POINT OF ORDER: I suspect that replies to this posting will be more on the
philosophical underpinnings and less on the appropriateness of unsigned and an
unsigned size_t in standard C++ & C, so please guard against
purely-philosophical off-topic postings to comp.std.c++.  I have tried to use a
certain line of reasoning to defend & advocate unsigned and an unsigned size_t
in standard C and C++ and in software-design models of reality expressed in
standard C & C++.  Thus I consider this posting firmly on-topic for comp.std.c++.



      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]




