www.digitalmars.com         C & C++   DMDScript  

D - Additional native types: dec, time?

reply "Jim Eberle" <jeberle1 my-deja.com> writes:
Any thoughts on providing language-level support for decimal (BCD) or time
values? These are fundamental quantities, yet nearly all languages relegate them
to the "just implement a class" bin.

D takes on things like complex numbers, and more complete support for floating
point arithmetic. Why not these?

Thanks,
Jim
Aug 20 2001
next sibling parent reply "Walter" <walter digitalmars.com> writes:
Time is readilly handled with a typedef'd long type (no need for a class).
I've never needed bcd in 20 years of coding, so that explains why it isn't
in the language <g>.

Jim Eberle wrote in message <9lrdih$qu4$1 digitaldaemon.com>...
Any thoughts on providing language-level support for decimal (BCD) or time
values? These are fundamental quantities, yet nearly all languages relegate
them
to the "just implement a class" bin.

D takes on things like complex numbers, and more complete support for
floating
point arithmetic. Why not these?

Thanks,
Jim
Aug 20 2001
next sibling parent Russell Bornschlegel <kaleja estarcion.com> writes:
Walter wrote:
 
 Time is readilly handled with a typedef'd long type (no need for a class).
 I've never needed bcd in 20 years of coding, so that explains why it isn't
 in the language <g>.
I'll restate that first sentence: "Time, measured in whole seconds from a reference point in the recent past, will be readily handled on 32-bit or bigger machines until a point in the not-too-distant future, and on 64-bit or bigger machines, for the foreseeable future." There's a lot of stuff that isn't covered there. :) -RB
Aug 20 2001
prev sibling parent reply Jan Knepper <jan smartsoft.cc> writes:
Walter wrote:

 Time is readilly handled with a typedef'd long type (no need for a class).
 I've never needed bcd in 20 years of coding, so that explains why it isn't
 in the language <g>.
20 years?! I thought you had more than that!
Aug 20 2001
parent reply "Walter" <walter digitalmars.com> writes:
Jan Knepper wrote in message <3B81E943.7515D927 smartsoft.cc>...
20 years?! I thought you had more than that!
<cough><cough>
Aug 21 2001
parent "Angus Graham" <agraham_d agraham.ca> writes:
"Walter" <walter digitalmars.com> wrote in message
 Jan Knepper wrote in message <3B81E943.7515D927 smartsoft.cc>...
20 years?! I thought you had more than that!
<cough><cough>
For lying on your resume you are hereby dismissed. Email me your compiler and escort yourself out of your house. Angus Graham
Aug 20 2001
prev sibling parent reply "Sean L. Palmer" <spalmer iname.com> writes:
Since we have no operator overloading, seems making vector and matrix
classes will not be easy.  I'd rather see builtin vector types than complex
numbers support.  After all, what is a complex number anyway if not a 1d
vector of 2 floats?  The properties of complex numbers extend out to 1d
vectors of more than 2 floats (3d points and vectors, anyone? 4d
quaternions/planes?) and from there fold out to 2d matrices and so on and so
forth.  I just don't see why one would think supporting the most basic
complex number case was such a profound technological leap that progress
should stop there.  Besides that, the D complex type seems to be oriented
towards double precision arithmetic only... and we game programmers tend to
prefer the smaller and faster float type in most cases.

Yes, in D we can already make vectors using static (or dynamic) arrays, but
we can't give them operations equivalent to floats, or complex.

Regarding BCD, well it'd be nice, but add too much bloat to a language
standard and you end up with zero conforming compilers.  Time can be well
represented by a count of seconds or microseconds or days and as such
deserves no special treatment by the language.... either use a long, or a
double.

Sean

"Jim Eberle" <jeberle1 my-deja.com> wrote in message
news:9lrdih$qu4$1 digitaldaemon.com...
 Any thoughts on providing language-level support for decimal (BCD) or time
 values? These are fundamental quantities, yet nearly all languages
relegate them
 to the "just implement a class" bin.

 D takes on things like complex numbers, and more complete support for
floating
 point arithmetic. Why not these?

 Thanks,
 Jim
Oct 16 2001
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
I agree that the language should include some sort of easy support for vectors
and matrices - if not through overloaded operators, then through natural types.
However, it's not as easy as it sounds you think it is.

"Sean L. Palmer" wrote:

 The properties of complex numbers extend out to 1d
 vectors of more than 2 floats (3d points and vectors, anyone? 4d
 quaternions/planes?) and from there fold out to 2d matrices and so on and so
 forth.
This is true with the structural properties, but not with the arithmetic ones. Addition works fine, but multiplying does not. (a+bi)*(c+di) = (ac-bd) +(ad+bc)i [ a b] * [ c d ] is undefined [ a ] [ c ] [ b ] * [ d ] is undefined [ a ] [ b] * [ c d ] = ac+bd and this doesn't cover dot products of vectors...
 I just don't see why one would think supporting the most basic
 complex number case was such a profound technological leap that progress
 should stop there.  Besides that, the D complex type seems to be oriented
 towards double precision arithmetic only... and we game programmers tend to
 prefer the smaller and faster float type in most cases.
Yes, it would be very desirable to support vectors and matrices of arbitrary types. Even matrices of ints are useful from time to time.
 Yes, in D we can already make vectors using static (or dynamic) arrays, but
 we can't give them operations equivalent to floats, or complex.
This is the same argument about infix operators as before. With so much 3D programming going on nowadays, IMHO not including matrix arithmetic in some form means D is much less likely to be used in those applications. If it is included (and highly optimized by the compiler), matrix math might be the "killer app" for the D language.
 Regarding BCD, well it'd be nice, but add too much bloat to a language
 standard and you end up with zero conforming compilers.  Time can be well
 represented by a count of seconds or microseconds or days and as such
 deserves no special treatment by the language.... either use a long, or a
 double.
Agreed. -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Oct 16 2001