Structure without a tag

  • Thread starter МакÑим Фомин
  • Start date
J

James Kuyper

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.
 
K

Keith Thompson

James Kuyper said:
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:


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.)
 
J

Joe Pfeiffer

gwowen said:
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.
 
S

Stephen Sprunk

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
 
T

Tim Rentsch

Eric Sosman said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,082
Messages
2,570,589
Members
47,212
Latest member
JaydenBail

Latest Threads

Top