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


Groups > comp.lang.c > #11740 > unrolled thread

Structure without a tag

Started byМаксим Фомин <maxim@maxim-fomin.ru>
First post2011-10-15 13:20 -0700
Last post2011-10-16 09:54 -0700
Articles 8 on this page of 28 — 18 participants

Back to article view | Back to comp.lang.c


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#11873

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2011-10-18 15:09 -0600
Message-ID<1bk482hur3.fsf@pfeifferfamily.net>
In reply to#11865
gwowen <gwowen@gmail.com> writes:

>> The CGS system does not make the speed of light 1. You're thinking of
>> Plank units.
>
> That's why carpenters are able to order materials using dimensionless
> numbers like "2 lots of 4 by 2" and "3 lots of 6 by 4".  They're using
> Plank units.

That's nice.  Subtle.

[toc] | [prev] | [next] | [standalone]


#11867

FromPatrick Scheible <kkt@zipcon.net>
Date2011-10-18 08:59 -0700
Message-ID<86lisi70k3.fsf@zipcon.net>
In reply to#11862
James Kuyper <jameskuyper@verizon.net> writes:

> No, you need a different unit for each currency.

Currencies are a mess.  Not only are they not comparable from country to
country, but they are not comparable from time period to time period.
Even the way they are adjusted for inflation is a political process.
People with different agendas pick measures of inflation that emphasize
or deemphasize it.  Making those choices, I think, is beyond the scope
of a programming language.

-- Patrick

[toc] | [prev] | [next] | [standalone]


#11869

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-10-18 12:54 -0400
Message-ID<4E9DAF54.7050600@verizon.net>
In reply to#11867
On 10/18/2011 11:59 AM, Patrick Scheible wrote:
> James Kuyper <jameskuyper@verizon.net> writes:
> 
>> No, you need a different unit for each currency.
> 
> Currencies are a mess.  Not only are they not comparable from country to
> country, but they are not comparable from time period to time period.
> Even the way they are adjusted for inflation is a political process.
> People with different agendas pick measures of inflation that emphasize
> or deemphasize it.  Making those choices, I think, is beyond the scope
> of a programming language.

I want to emphasize that what I'm about to say is NOT a proposed change
to C; just a feature that it would be entirely feasible to put in a new
language, and one that may be similar to a feature already supported by
some language I'm not familiar with:

It would be quite feasible for a programming language to enforce
dimensional analysis rules, and allow user-define dimensions such as
dollars_now and dollars_then. The user could then declare that
inflation_factor has the units "dollars_now / dollars_then". A program
that used a fixed reference year could define a unit such as dollars_2005.

Defining a system where a unit could be parametrized, such as
dollars['2011-10-18'] would be possible, but much more complicated, and
probably not worthwhile.

[toc] | [prev] | [next] | [standalone]


#11870 — Attributions (was Re: Structure without a tag)

FromKeith Thompson <kst-u@mib.org>
Date2011-10-18 11:48 -0700
SubjectAttributions (was Re: Structure without a tag)
Message-ID<lnwrc2nnkb.fsf_-_@nuthaus.mib.org>
In reply to#11862
James Kuyper <jameskuyper@verizon.net> writes:
> The last time I had to remind you of this was March 31st. Permission to
> quote any part of any message I post, without proper attribution, is
> denied. Your unjustified fear of being held responsible for falsely
> attributing quoted text to someone using a spoofed user id doesn't
> excuse you from your responsibility for properly attributing quotations.
>
> On 10/18/2011 04:04 AM, Gordon Burditt wrote:
[...]

And a solution that could satisfy everyone is *so* simple.
Gordon could just configure his newsreader to use different text
for the attribution line, something like:

Someone posting as James Kuyper <jameskuyper@verizon.net> writes:

Gordon cannot be held responsible for claiming that James wrote
the article, and everyone else can see that it almost certainly was.

Gordon, why don't you just do that?  (I grant you one-time permission
to quote my words from this article without attribution.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#11874

FromStephen Sprunk <stephen@sprunk.org>
Date2011-10-18 16:20 -0500
Message-ID<j7kqi7$luc$1@dont-email.me>
In reply to#11854
On 18-Oct-11 03:04, Gordon Burditt wrote:
> Back in physics class, there were something like 5 fundamental units
> and all the others could be expressed in terms of them:
> 
> 	distance, time, mass, electric charge, and temperature
> 
> This was referred to as the "MKS" system (meter, kilogram, second).
> Actually, there were a lot of combinations of 5 "fundamental units"
> you could use, the rule being that you're not allowed to have a
> "fundamental unit" expressable in terms of other "fundamental units",
> and you'd express the rest in terms of those 5.

There are seven base SI units (m, kg, s, A, K, mol, cd), from which all
other units are derived.

The original definitions of the base units were all interdependent,
though, and most of them still are.  The kilogram (which used to be
based on the litre, which is based on the metre) and second are the only
ones truly independent even today.

S

-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

[toc] | [prev] | [next] | [standalone]


#16165

FromTim Rentsch <txr@alumni.caltech.edu>
Date2012-01-24 18:05 -0800
Message-ID<kfnobtsbkq8.fsf@x-alumni2.alumni.caltech.edu>
In reply to#11742
Eric Sosman <esosman@ieee-dot-org.invalid> writes:

> On 10/15/2011 4:20 PM,  someone wrote:
>> Consider this code:
>>
>> struct
>> {
>>     int x;
>>     int y;
>> }  one;
>>
>> struct
>> {
>>     int x;
>>     int y;
>> }  two;
>>
>> int main(void)
>> {
>>     one.x = one.y = 6;
>>     one = two;
>>     return 0;
>> }
>>
>> Compiler rejects assignment of first structure to second
>> ("incompatible types when assigning to type 'struct<anonymous>' from
>> type 'struct<anonymous>'").
>>
>> It seems to me that objects one and two have type struct {int x; int
>> y} and therefore their types are equal.
>>
>> If not, which type they have?
>
>     The language Standard states the rules for "type compatibility,"
> and according to those rules the types of `one' and `two' are not
> compatible.  Yes, they look alike.  But they are not compatible, and
> you cannot assign from one to the other.  [snip]

More significantly, they are not "assignment conforming".
Assignment is allowed for many sets of types that aren't
compatible, or even "almost compatible".  The language
could have been defined so this structure assignment
would be allowed, and in fact it's less of a leap than
some other cases that are allowed.  But either way it's
the assignment operator that determines that, not (just)
type compatibility.

[toc] | [prev] | [next] | [standalone]


#11745

FromKeith Thompson <kst-u@mib.org>
Date2011-10-15 16:30 -0700
Message-ID<lnfwitrfy7.fsf@nuthaus.mib.org>
In reply to#11740
Максим Фомин <maxim@maxim-fomin.ru> writes:
> Consider this code:
>
> struct
> {
>    int x;
>    int y;
> }  one;
>
> struct
> {
>    int x;
>    int y;
> }  two;
>
> int main(void)
> {
>    one.x = one.y = 6;
>    one = two;
>    return 0;
> }
>
> Compiler rejects assignment of first structure to second
> ("incompatible types when assigning to type ‘struct <anonymous>’ from
> type ‘struct <anonymous>’").
>
> It seems to me that objects one and two have type struct {int x; int
> y} and therefore their types are equal.
>
> If not, which type they have?

If you had declared them with distinct tags:

    struct foo { int x; int y; } one;
    struct bar { int x; int y; } two;

they'd be of distinct and incompatible types, "struct foo" and "struct
bar".

Omitting the tags doesn't make them compatible.

If you want "one" and "two" to have compatible types, it's easy enough
to declare them that way, either:

    struct { int x; int y; } one, two;

or

    struct foo { int x; int y; };
    struct foo one;
    struct foo two;

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#11772

FromJean-Christophe <5.d@free.fr>
Date2011-10-16 09:54 -0700
Message-ID<e7e54573-0104-4cf4-a5af-b3d13a5a41cf@a9g2000yqo.googlegroups.com>
In reply to#11740
On 15 oct, 22:20, Максим Фомин

> struct
> {  int x;
>    int y;
> }  one;
>
> struct
> {  int x;
>    int y;
> }  two;


They are exacltly the same, so you don't
need two different structure declaration.

> int main(void)
> {
>    one.x = one.y = 6;
>    one = two;
>    return 0;
> }

Nah :


 int main(void)
 {
    one.x = one.y = 6;

    memcpy( &two, &one, sizeof(two) );

    return 0;
 }

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.c


csiph-web