www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Get rid of byte?

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Strictly speaking 'byte' is a name of data storage unit  and
not a name of numeric type. And by definition it is smallest addressable
unit by particular processor. ( Some DSP can address only 32bit bytes  for 
example )

So word combinations "signed byte" and "unsigned byte" are
technically incorrect.

Ideally (mathematically correct) it should be something like
int8, int16, int32, int64 and
nat8, nat16, nat32, nat64 for "unsigned"
real16, real32, real64, etc.

At least 'byte' should be unsigned numeric type ("what is max number stored 
in byte?")
as 'word' and 'dword'.

Andrew Fedoniouk.
http://terrainformatica.com
Feb 16 2006
next sibling parent nick <nick.atamas gmail.com> writes:
Since a definition is something that most people agree on, there isn't a
right and a wrong in these discussions. There is just consistent and
inconsistent. For our purposes, a 'byte' and a 'ubyte' make sense
because most people understand what those tokens mean; therefore they
are consistent.

Andrew Fedoniouk wrote:
 Strictly speaking 'byte' is a name of data storage unit  and
 not a name of numeric type.

needs to support low level access to data storage units present in hardware.
 And by definition it is smallest addressable
 unit by particular processor.( Some DSP can address only 32bit bytes  for 
 example )

usually used in more specific contexts. Generally people would say that a byte is 8 bits.
 So word combinations "signed byte" and "unsigned byte" are
 technically incorrect.

unsigned means it's not. I would be totally cool with the concept of a 'byte' being just 8 bits. However, I start getting crazy ideas like disallowing any arithmetic on bytes, since they are just collections of bits.
 Ideally (mathematically correct) it should be something like
 int8, int16, int32, int64 and
 nat8, nat16, nat32, nat64 for "unsigned"
 real16, real32, real64, etc.

of a number; it's not really a 'real'. If it was a real it wouldn't have rounding errors and such. Below, I am just trying to illustrate that there is no end to being picky with definitions...
 At least 'byte' should be unsigned numeric type ("what is max number stored 
 in byte?")
 as 'word' and 'dword'.

there is no maximum number stored in a byte. Instead, we assign meaning to different configurations that a byte can take on (of which there are 256). For example, you could say 0xFF means 'infinity' or it can mean '42', or it can mean 'I <3 PONIES'.
 Andrew Fedoniouk.
 http://terrainformatica.com

Feb 17 2006
prev sibling parent reply Marco Matthies <mcm-news moinmarco.de> writes:
Andrew Fedoniouk wrote:
 Strictly speaking 'byte' is a name of data storage unit  and
 not a name of numeric type.

True.
 And by definition it is smallest addressable
 unit by particular processor. ( Some DSP can address only 32bit bytes  for 
 example )

This ("smallest addressable unit") is not the definition of byte (e.g. certain architectures do not allow loads which are not 32-bit aligned and always load a 32-bit quantity but still have byte == 8 bits). Historically, it just meant tuple (or array if you want) of bits with an architecture dependent length (e.g. 6-bit bytes were the first used byte-size as the machines of long ago used 6-bit character sets). Well then was then and now is now, and nowadays everyone usually means "8 bits" when they say "byte".
 So word combinations "signed byte" and "unsigned byte" are
 technically incorrect.
 Ideally (mathematically correct) it should be something like
 int8, int16, int32, int64 and
 nat8, nat16, nat32, nat64 for "unsigned"
 real16, real32, real64, etc.

I like your idea, here is my variation on it: int8, int16, int32, int64, int128 uint8, uint16, uint32, uint64, uint128 float32, float64, float80, float128 ifloat32, ifloat64, ifloat80, ifloat128 cfloat32, cfloat64, cfloat80, cfloat128 But you'd actually have to look at code containing lots of this -- perhaps it just turns out too ugly. Marco
Feb 17 2006
parent reply S. Chancellor <S._member pathlink.com> writes:
In article <dt5ba1$h5n$1 digitaldaemon.com>, Marco Matthies says...

I like your idea, here is my variation on it:

int8,  int16,  int32,  int64,  int128
uint8, uint16, uint32, uint64, uint128
float32,  float64,  float80,  float128
ifloat32, ifloat64, ifloat80, ifloat128
cfloat32, cfloat64, cfloat80, cfloat128

But you'd actually have to look at code containing lots of this -- 
perhaps it just turns out too ugly.

Marco

This is very common in cross platform C applications. Typdefs from the types of a specific artitecture to these size style types so they don't have to remember what arch they're on everywhere. It doesn't look bad to me at all. -S.
Feb 17 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"S. Chancellor" <S._member pathlink.com> wrote in message 
news:dt5do3$jh1$1 digitaldaemon.com...
 In article <dt5ba1$h5n$1 digitaldaemon.com>, Marco Matthies says...

I like your idea, here is my variation on it:

int8,  int16,  int32,  int64,  int128
uint8, uint16, uint32, uint64, uint128
float32,  float64,  float80,  float128
ifloat32, ifloat64, ifloat80, ifloat128
cfloat32, cfloat64, cfloat80, cfloat128

But you'd actually have to look at code containing lots of this -- 
perhaps it just turns out too ugly.

Marco

This is very common in cross platform C applications. Typdefs from the types of a specific artitecture to these size style types so they don't have to remember what arch they're on everywhere. It doesn't look bad to me at all.

This is unnecessary in D, as ints are 32 bits everywhere. A typedef or other reminder isn't necessary.
Feb 17 2006
parent reply Bruno Medeiros <daiphoenixNO SPAMlycos.com> writes:
Walter Bright wrote:
 "S. Chancellor" <S._member pathlink.com> wrote in message 
 news:dt5do3$jh1$1 digitaldaemon.com...
 In article <dt5ba1$h5n$1 digitaldaemon.com>, Marco Matthies says...

 I like your idea, here is my variation on it:

 int8,  int16,  int32,  int64,  int128
 uint8, uint16, uint32, uint64, uint128
 float32,  float64,  float80,  float128
 ifloat32, ifloat64, ifloat80, ifloat128
 cfloat32, cfloat64, cfloat80, cfloat128

 But you'd actually have to look at code containing lots of this -- 
 perhaps it just turns out too ugly.

 Marco

types of a specific artitecture to these size style types so they don't have to remember what arch they're on everywhere. It doesn't look bad to me at all.

This is unnecessary in D, as ints are 32 bits everywhere. A typedef or other reminder isn't necessary.

Still, it might be nice to have those types in the language, as aliases. It could be a good name alternative, in some situations, to using the new names(like real or cent) for every new size that has come up. -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural."
Feb 18 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
news:dt705s$1vkh$1 digitaldaemon.com...
 Still, it might be nice to have those types in the language, as aliases. 
 It could be a good name alternative, in some situations, to using the new 
 names(like real or cent) for every new size that has come up.

import std.stdint;
Feb 18 2006
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Walter Bright" <newshound digitalmars.com> wrote in message 
news:dt7mur$2hvs$2 digitaldaemon.com...
 "Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
 news:dt705s$1vkh$1 digitaldaemon.com...
 Still, it might be nice to have those types in the language, as aliases. 
 It could be a good name alternative, in some situations, to using the new 
 names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.
Feb 18 2006
next sibling parent reply "Walter Bright" <newshound digitalmars.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:dt7q7f$2kfm$1 digitaldaemon.com...
 "Walter Bright" <newshound digitalmars.com> wrote in message 
 news:dt7mur$2hvs$2 digitaldaemon.com...
 "Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
 news:dt705s$1vkh$1 digitaldaemon.com...
 Still, it might be nice to have those types in the language, as aliases. 
 It could be a good name alternative, in some situations, to using the 
 new names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

I agree it's ugly, but the names were taken from C's <stdint>. That makes it convenient for porting from C, and for those who like the C stuff. Having yet a third set of names would be a bit too redundant.
Feb 18 2006
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Walter Bright" <newshound digitalmars.com> wrote in message 
news:dt7uv8$2p0l$2 digitaldaemon.com...
 I agree it's ugly, but the names were taken from C's <stdint>. That makes 
 it convenient for porting from C, and for those who like the C stuff. 
 Having yet a third set of names would be a bit too redundant.

You could just change it altogether, since it's easy to globally search and replace for intxx_t. Besides, how many C programs have you seen that _actually use the stdints_? It seems every open-source project out there has its own set of defines or typedefs to rename the types whatever they want, be it int8, byte, i8 or something else altogether. Of course, this is never going to change, so I'm not sure why I even bother.
Feb 18 2006
next sibling parent Marco Matthies <mcm-news moinmarco.de> writes:
Jarrett Billingsley wrote:
 You could just change it altogether, since it's easy to globally search and 
 replace for intxx_t.  Besides, how many C programs have you seen that 
 _actually use the stdints_?  It seems every open-source project out there 
 has its own set of defines or typedefs to rename the types whatever they 
 want, be it int8, byte, i8 or something else altogether.

Well here is one example: qemu. No doubt a bazillion C programs don't use stdint.h, but that is probably due to the fact it only appeared in C99. Marco
Feb 18 2006
prev sibling parent "Walter Bright" <newshound digitalmars.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:dt7vhe$2phg$1 digitaldaemon.com...
 Of course, this is never going to change, so I'm not sure why I even 
 bother.

If it was changed, there'd inevitably be someone who thought it would be a great idea to use the stdint.h names and who'd think ill of me for not making that change. There's no solution possible. At some point, it's time to just leave it be and move on to more interesting things.
Feb 19 2006
prev sibling parent "Chris Miller" <chris dprogramming.com> writes:
On Sat, 18 Feb 2006 14:59:42 -0500, Walter Bright  
<newshound digitalmars.com> wrote:

 "Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message
 news:dt7q7f$2kfm$1 digitaldaemon.com...
 "Walter Bright" <newshound digitalmars.com> wrote in message
 news:dt7mur$2hvs$2 digitaldaemon.com...
 "Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message
 news:dt705s$1vkh$1 digitaldaemon.com...
 Still, it might be nice to have those types in the language, as  
 aliases.
 It could be a good name alternative, in some situations, to using the
 new names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

I agree it's ugly, but the names were taken from C's <stdint>. That makes it convenient for porting from C, and for those who like the C stuff. Having yet a third set of names would be a bit too redundant.

Could deprecate them, and/or have them in std.c.stdint, and add ones without _t to std.stdint.
Feb 18 2006
prev sibling next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Jarrett Billingsley wrote:

 Could the _t suffix at least be taken off those aliases (alii?) ?  int8_t 
 has got to be one of the ugliest things I've seen since CLK_TCK. 

It also appears on "size_t", the type of the array .length attribute... (that is similar to "uint" for 32-bit code and "ulong" for 64-bit code) So it's in D already :-) --anders PS. I liked the "std.stdutf" idea too, but it seems noone else did. alias char utf8_t; alias wchar utf16_t; alias dchar utf32_t;
Feb 19 2006
prev sibling parent reply James Dunne <james.jdunne gmail.com> writes:
Jarrett Billingsley wrote:
 "Walter Bright" <newshound digitalmars.com> wrote in message 
 news:dt7mur$2hvs$2 digitaldaemon.com...
 
"Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
news:dt705s$1vkh$1 digitaldaemon.com...

Still, it might be nice to have those types in the language, as aliases. 
It could be a good name alternative, in some situations, to using the new 
names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

FYI, the -i plural suffix only applies to words that end in 'us', not 'as' or other variants. cactus -> cacti genius -> genii hippopotamus -> hippopotami Apparently, 'bus' is the exception to the rule. "Hey look at all those bi!" An interesting read: http://www.csse.monash.edu.au/~damian/papers/extabs/Plurals.html -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O M-- V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ r+++ y+++ ------END GEEK CODE BLOCK------ James Dunne
Feb 20 2006
next sibling parent reply "John C" <johnch_atms hotmail.com> writes:
"James Dunne" <james.jdunne gmail.com> wrote in message 
news:dtdehf$2pu7$1 digitaldaemon.com...
 Jarrett Billingsley wrote:
 "Walter Bright" <newshound digitalmars.com> wrote in message 
 news:dt7mur$2hvs$2 digitaldaemon.com...

"Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
news:dt705s$1vkh$1 digitaldaemon.com...

Still, it might be nice to have those types in the language, as aliases. 
It could be a good name alternative, in some situations, to using the 
new names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

FYI, the -i plural suffix only applies to words that end in 'us', not 'as' or other variants. cactus -> cacti genius -> genii hippopotamus -> hippopotami Apparently, 'bus' is the exception to the rule. "Hey look at all those bi!"

Call me a pedant (it wouldn't be the first time), but 'bus' is just one of many exceptions. corpus corpora viscus viscera platypus platypuses opus opera virus viruses (although see "Use of the virii form" at http://en.wikipedia.org/wiki/Viruses) Bus, of course, is short for omnibus, which in Latin was a plural anyway.
 An interesting read: 
 http://www.csse.monash.edu.au/~damian/papers/extabs/Plurals.html

 -- 
 -----BEGIN GEEK CODE BLOCK-----
 Version: 3.1
 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
 M--  V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ 
 r+++ y+++
 ------END GEEK CODE BLOCK------

 James Dunne 

Feb 20 2006
parent reply James Dunne <james.jdunne gmail.com> writes:
John C wrote:
 "James Dunne" <james.jdunne gmail.com> wrote in message 
 news:dtdehf$2pu7$1 digitaldaemon.com...
 
Jarrett Billingsley wrote:

"Walter Bright" <newshound digitalmars.com> wrote in message 
news:dt7mur$2hvs$2 digitaldaemon.com...


"Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
news:dt705s$1vkh$1 digitaldaemon.com...


Still, it might be nice to have those types in the language, as aliases. 
It could be a good name alternative, in some situations, to using the 
new names(like real or cent) for every new size that has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

FYI, the -i plural suffix only applies to words that end in 'us', not 'as' or other variants. cactus -> cacti genius -> genii hippopotamus -> hippopotami Apparently, 'bus' is the exception to the rule. "Hey look at all those bi!"

Call me a pedant (it wouldn't be the first time), but 'bus' is just one of many exceptions. corpus corpora viscus viscera platypus platypuses opus opera virus viruses (although see "Use of the virii form" at http://en.wikipedia.org/wiki/Viruses) Bus, of course, is short for omnibus, which in Latin was a plural anyway.
An interesting read: 
http://www.csse.monash.edu.au/~damian/papers/extabs/Plurals.html

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--  V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ 
r+++ y+++
------END GEEK CODE BLOCK------

James Dunne 


Learn something new everyday. I did know 'bus' was short for something, but I didn't know that. I'm not a fan of the -uses plural suffix. I prefer the -i plural. Platypus = platypi. It just sounds more natural to me. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O M-- V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ r+++ y+++ ------END GEEK CODE BLOCK------ James Dunne
Feb 21 2006
parent Georg Wrede <georg.wrede nospam.org> writes:
James Dunne wrote:
 John C wrote:
 
 "James Dunne" <james.jdunne gmail.com> wrote in message 
 news:dtdehf$2pu7$1 digitaldaemon.com...

 Jarrett Billingsley wrote:

 "Walter Bright" <newshound digitalmars.com> wrote in message 
 news:dt7mur$2hvs$2 digitaldaemon.com...


 "Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
 news:dt705s$1vkh$1 digitaldaemon.com...


 Still, it might be nice to have those types in the language, as 
 aliases. It could be a good name alternative, in some situations, 
 to using the new names(like real or cent) for every new size that 
 has come up.

import std.stdint;

Could the _t suffix at least be taken off those aliases (alii?) ? int8_t has got to be one of the ugliest things I've seen since CLK_TCK.

FYI, the -i plural suffix only applies to words that end in 'us', not 'as' or other variants. cactus -> cacti genius -> genii hippopotamus -> hippopotami Apparently, 'bus' is the exception to the rule. "Hey look at all those bi!"

Call me a pedant (it wouldn't be the first time), but 'bus' is just one of many exceptions. corpus corpora viscus viscera platypus platypuses opus opera virus viruses (although see "Use of the virii form" at http://en.wikipedia.org/wiki/Viruses) Bus, of course, is short for omnibus, which in Latin was a plural anyway.
 An interesting read: 
 http://www.csse.monash.edu.au/~damian/papers/extabs/Plurals.html

 -- 
 -----BEGIN GEEK CODE BLOCK-----
 Version: 3.1
 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- 
 O M--  V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
 h>--->++ r+++ y+++
 ------END GEEK CODE BLOCK------


Learn something new everyday. I did know 'bus' was short for something, but I didn't know that. I'm not a fan of the -uses plural suffix. I prefer the -i plural. Platypus = platypi. It just sounds more natural to me.

So be it. Then you probably know the pluralis of 'sauna'.
Feb 22 2006
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"James Dunne" <james.jdunne gmail.com> wrote in message 
news:dtdehf$2pu7$1 digitaldaemon.com...
 FYI, the -i plural suffix only applies to words that end in 'us', not 
 'as' or other variants.


Ah!
 Apparently, 'bus' is the exception to the rule.  "Hey look at all those 
 bi!"


Lol, of course that phrase could come up in certain situations ;)
Feb 20 2006
prev sibling parent Bruno Medeiros <daiphoenixNO SPAMlycos.com> writes:
Walter Bright wrote:
 "Bruno Medeiros" <daiphoenixNO SPAMlycos.com> wrote in message 
 news:dt705s$1vkh$1 digitaldaemon.com...
 Still, it might be nice to have those types in the language, as aliases. 
 It could be a good name alternative, in some situations, to using the new 
 names(like real or cent) for every new size that has come up.

import std.stdint;

Hum, interesting, didn't remember about that. Nice, but should also: not have the "_t" idiom; have similar aliases for floating point types (float32, float64, float80, etc.) -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural."
Feb 18 2006