3 ms·
It's totally true, using sizeof like a function is one of my pet peeves. Even the kernel people do it but it's WRONG and you are right. But ACSHUALLY, how you
by jstimpfle 4mo ago
It's totally true, using sizeof like a function is one of my pet peeves. Even the kernel people do it but it's WRONG and you are right.
But ACSHUALLY, how you write allocation is like this
#define sane_alloc(type, count) ((type *) malloc(sizeof (type) * (count)))
game->boardPieces = sane_alloc(BoardPiece, row * column);
The kernel people seem to finally have figured out this one in 2026.
- DonHopkins 4mo agoNothing is sane in a language that lets you say 4["Foo!"] Array indexing in C is just pointer arithmetic wearing Groucho Marx Glasses. C combines the flexibility and power of assembly language with the user-friendliness of assembly language.
- jstimpfle 4mo ago> Nothing is sane in a language that lets you say 4["Foo!"] I just had a look at your HN profile page and was struck by the irony of seeing your Forth vs Lisp vs Postscript code examples there. Now consider that I've never written code like 4["Foo!"], even though I know it's possible, but in other languages you constantly have to do mental gymnastics to get any real work done, and those are allegedly so much saner !???
- DonHopkins 4mo agoWhen they were handing out brains, I though they said suᴉɐɹq, and I said "180 rotate".
- unwind 4mo agoNah I'm still against repeating the type name all over the place, and the cast adds nothing good imnsho.
- jstimpfle 4mo agoThe cast is at least 50% of why this is useful! You'll now get compile errors in case you did anything wrong.