problem with size_t and an easy solution
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Sun Dec 7 17:30:24 PST 2014
Hello.
i don't like `size_t`. for many month i avoied using it wherever that
was possible, 'cause i feel something wrong with it. and today i found
the soultion!
let's see how other D types are named: `int`, `uint`, `byte` (oh, well,
this name sux), `ulong`. see the pattern? so i decided to rename
`size_t` to `usize`. and you know what? it immidiately started to be
familiar. like a thing that was always here, simply dressed in patches.
let's face it: that ugly '_t' is alien to D. this is an ugly leftover
from C, and this leftover is nonsence. it will not really help anyone,
but it immideately turns D code to badly-looking crap. see for yourself:
size_t countSomeElements();
and
usize countSomeElements();
`size_t` looking like an alien here, ruining all the style.
i propose to introduce `usize` and `sptrdiff` along with those '_t'
uglyness, and then slowly migrate all the code to the new names.
yes, this is another "cosmetic issue", but let me tell you that such
"purely cosmetic things" are really important for those who just
starting to learn the language.
it's impossible to write nice D code with `size_t`: we have either
alias it each time or use `uint`/`ulong` to make our code looks good.
really, i've seen people who using `uint` instead of `size_t`, 'cause
"with size_t my code looks ugly, and i tired of aliasing that shit
every time". ah, yep, their code sux for 64 bits, but: "i know that
64-bit size_t is... 64-bit. i'll fix that later, maybe."
uglyness leads to bad code. let's kill `size_t` for good!
p.s. some of you may think that i'm trolling. i can assure you that
this post is not trolling, this is just another try to talk about
"purely cosmetic issues" and how they hurts the language, especially
for beginners. when beginner see such "pure cosmetic issue", he
starting to think that the whole language is a mess: "hey, this is such
easy to fix, but they never bother to... i bet the other parts of the
language are even worse." and you know what? it's enough to make such
mistake two or three times to make people believe that D is a "dirty
and hackish language without clear style". "this is uuuugly" is *the*
*argument*.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141208/23a7219e/attachment.sig>
More information about the Digitalmars-d
mailing list