Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #11824

Re: Structure without a tag

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Structure without a tag
Date 2011-10-17 13:53 -0400
Organization A noiseless patient Spider
Message-ID <4E9C6BA2.2030504@verizon.net> (permalink)
References (2 earlier) <4E9AE7ED.3C025A9B@btinternet.com> <slrnj9mlh2.1bk.grahn+nntp@frailea.sa.invalid> <j7flu0$5su$1@dont-email.me> <j7frga$8ou$1@dont-email.me> <20111017125705.251@kylheku.com>

Show all headers | View raw


On 10/17/2011 01:02 PM, Kaz Kylheku wrote:
> On 2011-10-17, James Kuyper <jameskuyper@verizon.net> wrote:
>> On 10/16/2011 06:29 PM, Eric Sosman wrote:
>> ...
>>>      Note that you probably don't want to forbid all mixtures of
>>> types, even in simple arithmetic.  For example,
>>>
>>> 	weight / (height * height * height) * shapeFactor
>>>
>>> might be a perfectly valid calculation of density.
>>
>> Unit-based constraints don't come into play in multiplication and
>> division.  The result simply has units that are determined by the units
>> of the operands. The relevant constraints apply to addition and
>> subtraction, comparison (for order or for equality), and assignment - It
>> only makes sense to perform any of those operations between operands
>> that have the same units.
> 
> But constraints could enter into multiplication. You could have a rule base
> which gives valid combinations of units, making it an error to, say, multiply
> the number of calories in a cookie by the voltage across a resistor.

You could impose such a rule if you want, but it's not a standard part
of the general concept of unit conversions. There's no inherent reason
why such a product could not be meaningful - a quantity with those units
it might occur as one of the coefficients in the equation describing a
curve that has been fitted to data connecting the voltage applied to an
electric oven to the number of calories in the resulting cookies.

> Suppose A arises as the result of multiplying Newtons by meters, and B arises
> as a result of multiplying kilograms, meters and dividing by seconds squared.
> You might want to be able to add these together.

Perhaps you meant "multiplying kilograms, meters squared and dividing by
seconds squared"? Otherwise, it doesn't work.

With that correction, A and B would have the same units, because of the
definition of Newtons as kg m/s^2. Addition of quantities with arbitrary
different set of units does not make sense. Adding A to B (after this
correction) could make sense, because the connection between Newtons,
kilograms, meters and seconds is NOT arbitrary.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Structure without a tag Максим Фомин <maxim@maxim-fomin.ru> - 2011-10-15 13:20 -0700
  Re: Structure without a tag Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-15 17:16 -0400
    Re: Structure without a tag Frederick Williams <freddywilliams@btinternet.com> - 2011-10-16 15:19 +0100
      Re: Structure without a tag Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-16 10:30 -0400
      Re: Structure without a tag Keith Thompson <kst-u@mib.org> - 2011-10-16 13:54 -0700
      Re: Structure without a tag Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-10-16 22:09 +0000
        Re: Structure without a tag Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-16 18:29 -0400
          Re: Structure without a tag "BartC" <bc@freeuk.com> - 2011-10-16 23:55 +0100
            Re: Structure without a tag blp@cs.stanford.edu (Ben Pfaff) - 2011-10-16 17:31 -0700
          Re: Structure without a tag James Kuyper <jameskuyper@verizon.net> - 2011-10-16 20:05 -0400
            Re: Structure without a tag Kaz Kylheku <kaz@kylheku.com> - 2011-10-17 17:02 +0000
              Re: Structure without a tag James Kuyper <jameskuyper@verizon.net> - 2011-10-17 13:53 -0400
                Re: Structure without a tag Robert Wessel <robertwessel2@yahoo.com> - 2011-10-17 13:38 -0500
                Re: Structure without a tag Максим Фомин <maxim@maxim-fomin.ru> - 2011-10-17 22:28 -0700
                Re: Structure without a tag gordonb.b1148@burditt.org (Gordon Burditt) - 2011-10-18 03:04 -0500
                Re: Structure without a tag Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-10-18 01:37 -0700
                Re: Structure without a tag James Kuyper <jameskuyper@verizon.net> - 2011-10-18 07:10 -0400
                Re: Structure without a tag gwowen <gwowen@gmail.com> - 2011-10-18 08:43 -0700
                Re: Structure without a tag James Kuyper <jameskuyper@verizon.net> - 2011-10-18 11:55 -0400
                Re: Structure without a tag "BartC" <bc@freeuk.com> - 2011-10-18 17:18 +0100
                Re: Structure without a tag Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-10-18 15:09 -0600
                Re: Structure without a tag Patrick Scheible <kkt@zipcon.net> - 2011-10-18 08:59 -0700
                Re: Structure without a tag James Kuyper <jameskuyper@verizon.net> - 2011-10-18 12:54 -0400
                Attributions (was Re: Structure without a tag) Keith Thompson <kst-u@mib.org> - 2011-10-18 11:48 -0700
                Re: Structure without a tag Stephen Sprunk <stephen@sprunk.org> - 2011-10-18 16:20 -0500
    Re: Structure without a tag Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-24 18:05 -0800
  Re: Structure without a tag Keith Thompson <kst-u@mib.org> - 2011-10-15 16:30 -0700
  Re: Structure without a tag Jean-Christophe <5.d@free.fr> - 2011-10-16 09:54 -0700

csiph-web