News for hackers. Stuff that matters.
Re:Baby Steps: Slowly Porting Musl to Rust by burfog on Saturday June 25, 2016 @01:25AM (#11975351)
Probably you'd end up with this:

foo->bar(foo,arg1,arg2)

It's not as simple-looking, but that isn't all bad. It's very clear what is going on. The overhead isn't hidden.

Things needing call-back functions need to support an extra void* of course, and sadly it is often left out.

Understanding how compilers translate C into assembly is a skill that must be practiced. I suggest getting in the habit of looking at the binary. After a while, you will know what to expect. The optimizers are not magic. They do fairly predictable transformations on the code. You can get a feel for when hand-optimization matters, and when it is just pointless. An awareness of cache lines and TLB entries is helpful too.

Re:Baby Steps: Slowly Porting Musl to Rust by lmm on Monday June 27, 2016 @09:15AM (#11985937)
> Things needing call-back functions need to support an extra void* of course, and sadly it is often left out.

Well when doing the right thing means writing more verbose code, it's no surprise that people do the quick-and-dirty thing (see http://www.haskellforall.com/2016/04/worst-practices-should-... ). Since "everyone knows" that best practice for a callback is to take a function pointer and a void * , wouldn't it be better to have that idiom built into the language? (i.e. a concise syntax for the pair of callback-and-void * , and a concise syntax for "invoking" the pair, passing the extra void * along with the "ordinary" arguments).