Dtype_dispatch: a macro that defines macros that define enums and match them

17 pointsposted 3 days ago
by mwlon

3 Comments

artemonster

2 days ago

this is an obvious case of battling the type system that just gets in the way. The "before" version obviously sucks, but the "after" with magic sprinkled in - sucks even more! is there an alternative solution?

smusamashah

2 days ago

I dont understand what's going on but it looks like a hack to avoid code duplication. We should be OK with duplication sometimes because it's more explicit and straightforward to mingle and debug.

ValentinA23

2 days ago

>In Pcodec I now have 9 data types and 47 matches

So 9 * 47 - 47 = 376 lines the author got rid of ? Which would imply that if he adds a tenth datatype, he doesn't have to update 47 match blocks sprinkled over the whole code base ?