clay icon indicating copy to clipboard operation
clay copied to clipboard

RFC: rename bitcast to refcast, reimplement bitcast as a bitwise copy

Open jckarter opened this issue 13 years ago • 4 comments

What do you guys think of renaming the current bitcast primitive, which returns a reference of a new type to the same memory, to refcast, and having bitcast actually bitwise-copy a new value? bitcast could then be less restrictive about the types it casts, since the destination type could have less strict alignment than the source.

jckarter avatar Oct 15 '12 02:10 jckarter

Intuitively I would take any 'cast' to be in place. How about a bitcopy primitive for the latter case?

ghost avatar Oct 15 '12 11:10 ghost

My worry is that the alignment requirement for bitcast is too restrictive, and might hinder casts you'd expect to work on some platforms, for instance if an Int64 is 4-byte-aligned but a Double is 8-byte-aligned as in some x86-32 ABIs.

jckarter avatar Oct 15 '12 16:10 jckarter

I guess my concern is not so much with the change to refcast which I think works just fine, but using a name that more accurately represents whats happening under the bonnet with the 'cast with copy to ensure correct alignment' case. copycast, alignedcast, or whatever. Maybe that's too much syntactic bike-shedding . . .

ghost avatar Oct 15 '12 16:10 ghost

Change of heart on this one, alternatives aren't really preferable to keeping bitcast. +1 for proposed changes.

ghost avatar Nov 10 '12 12:11 ghost