www.digitalmars.com         C & C++   DMDScript  

D - size of type

reply nicO <nicolas.boulay ifrance.com> writes:
My post called "OpenMP, and set" is maybe to big, nobody give an answer
to it.

One of the proposal is to use interval instead of type.
ex: [0..15] i; //to define a little integer which could became a 8 or
even 4 bits integer depending of the cpu.
A letter could be used to defined from which mathematical set the number
should come from math (N,Q,R,...).

ex: N[0..15] i; 
    R[10.0..2000.3] f;

So it could be possible to make an analyse to verify that i should never
exeded 15. It could be done dynamicaly or staticly (cf the previous
post).

nicO
Aug 24 2001
next sibling parent "Walter" <walter digitalmars.com> writes:
I was thinking of adding that as an extension in version 2. -Walter

nicO wrote in message <3B869A3C.AC3A1725 ifrance.com>...
My post called "OpenMP, and set" is maybe to big, nobody give an answer
to it.

One of the proposal is to use interval instead of type.
ex: [0..15] i; //to define a little integer which could became a 8 or
even 4 bits integer depending of the cpu.
A letter could be used to defined from which mathematical set the number
should come from math (N,Q,R,...).

ex: N[0..15] i;
    R[10.0..2000.3] f;

So it could be possible to make an analyse to verify that i should never
exeded 15. It could be done dynamicaly or staticly (cf the previous
post).

nicO
Aug 24 2001
prev sibling parent reply "Angus Graham" <agraham_d agraham.ca> writes:
"nicO" <nicolas.boulay ifrance.com> wrote

 One of the proposal is to use interval instead of type.
 ex: [0..15] i; //to define a little integer which could became a 8 or
 even 4 bits integer depending of the cpu.
 A letter could be used to defined from which mathematical set the number
 should come from math (N,Q,R,...).
Personally I've never had a problem with: int Angus Graham
Aug 24 2001
parent reply nicO <nicolas.boulay ifrance.com> writes:
Angus Graham a écrit :
 
 "nicO" <nicolas.boulay ifrance.com> wrote
 
 One of the proposal is to use interval instead of type.
 ex: [0..15] i; //to define a little integer which could became a 8 or
 even 4 bits integer depending of the cpu.
 A letter could be used to defined from which mathematical set the number
 should come from math (N,Q,R,...).
Personally I've never had a problem with: int Angus Graham
The idea is to improve the language. Simple int is composed by 16, 32 or 64 bits ? How to choose ? If you give a range the compiler could use the best size for the targeted cpu. You could say 32 is enought. Most of the time yes. But with new SIMD stuff, it could be very interresting to know if 16 will not be enought because twice number of operations could be perform in the same time. Beside that some "proofs" could be done on the program. (such value is never reach and so on) To make safer program, it could be very interresting. nicO
Aug 25 2001
parent reply "Angus Graham" <agraham_d agraham.ca> writes:
"nicO" <nicolas.boulay ifrance.com>

 Personally I've never had a problem with:

 int
The idea is to improve the language. Simple int is composed by 16, 32 or 64 bits ? How to choose ? If you give a range the compiler could use the best size for the targeted cpu. You could say 32 is enought. Most of the time yes. But with new SIMD stuff, it could be very interresting to know if 16 will not be enought because twice number of operations could be perform in the same time
I guess I wouldn't be opposed to this ranged system, as long as plain old "int" was still there. I need to be able to do a certain amount of my coding with my brain in "off" mode. I don't want every time I create an integer variable to have to ask myself "hmm, what is the range of this number?" Right now I can just think "Is two billion enough?" And the answer is always yes. Angus
Aug 25 2001
next sibling parent nicO <nicolas.boulay ifrance.com> writes:
Angus Graham a écrit :
 
 "nicO" <nicolas.boulay ifrance.com>
 
 Personally I've never had a problem with:

 int
The idea is to improve the language. Simple int is composed by 16, 32 or 64 bits ? How to choose ? If you give a range the compiler could use the best size for the targeted cpu. You could say 32 is enought. Most of the time yes. But with new SIMD stuff, it could be very interresting to know if 16 will not be enought because twice number of operations could be perform in the same time
I guess I wouldn't be opposed to this ranged system, as long as plain old "int" was still there. I need to be able to do a certain amount of my coding with my brain in "off" mode. I don't want every time I create an integer variable to have to ask myself "hmm, what is the range of this number?" Right now I can just think "Is two billion enough?" And the answer is always yes.
A typedef could be used to defined what is a int. So there is no problem for it. So for security raison and performance, given a more precise hint, will help a lot the compiler. nicO
 Angus
Aug 26 2001
prev sibling parent "Walter" <walter digitalmars.com> writes:
Angus Graham wrote in message <9m9n85$d2v$1 digitaldaemon.com>...
I guess I wouldn't be opposed to this ranged system, as long as plain old
"int" was still there.  I need to be able to do a certain amount of my
coding with my brain in "off" mode.  I don't want every time I create an
integer variable to have to ask myself "hmm, what is the range of this
number?"  Right now I can just think "Is two billion enough?"  And the
answer is always yes.
I think you're on to something. D offers lots of help from the compiler and runtime for finding bugs, but it's also designed so you can just bang out quick & dirty code. For example, when writing a simple utility, it's just tedious writing all the error handling code. With D, you can just let the default error handling mechanism deal with it. Int ranges are a good idea, but as an optional specification.
Aug 26 2001