News for hackers. Stuff that matters.
Re:Mal – Make a Lisp, in 68 languages by kazinator on Tuesday September 12, 2017 @09:42PM (#15234805)
This code could take advantage of the fact that the type is a union.

One can bend the rules of prim-and-proper well-defined ISO C just a little bit and assign to the simplest function pointer, taking advantage of all function pointers having the same representation on every machine known to mortal hacker, and all being overlaid by the union. Thus all the cases collapse down to this:

   mv->val.u.f0 = (void (*)(void)) func;
done. Now if this is 13 arguments, then strictly speaking, accessing mv->val.uf13 is not well-defined behavior. That's only going to be problem when it actually doesn't work, though. A big problem, then. :)
Re:Mal – Make a Lisp, in 68 languages by gbacon on Wednesday September 13, 2017 @02:10PM (#15240952)
I can respect the author taking the trouble to avoid undefined behavior. Technically correct is the best kind of correct.
Re:Mal – Make a Lisp, in 68 languages by kazinator on Wednesday September 13, 2017 @06:42PM (#15243414)
That sort of love affair with ISO gospel lands on the rocks as soon as your Lisp stuffs a couple of tag bits into a C pointer.