On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:
>It's been a long, long while since I published anything on the blog. I do intend to get pick it up again down the road, but Walter recently surprised me with plans of his own. He's taken the topic of his DConf '23 talk and derived a blog post from it:
https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/
I guess he got impatient with the pace at which I'm getting the talk videos uploaded :-)
And for anyone who'd like to engage in any Reddit discussion that comes up:
https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/
I wonder if Walter has an opinion on this. In a .c file:
void *(STDVEC_DATAPTR)(SEXP x) {
if (ALTREP(x))
error("cannot get STDVEC_DATAPTR from ALTREP object");
if (! isVector(x) && TYPEOF(x) != WEAKREFSXP)
error("STDVEC_DATAPTR can only be applied to a vector, not a '%s'",
type2char(TYPEOF(x)));
CHKZLN(x);
return STDVEC_DATAPTR(x);
}
CHKZLN(x)
only does some checks. It doesn't have any side effects. After scratching my head for a bit, I used grep to locate this in a .h file:
#define STDVEC_DATAPTR(x) ((void *) (((SEXPREC_ALIGN *) (x)) + 1))
And of course, there were no comments to explain what is going on. Very self-evident.