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

Open
jckarter opened this Issue Oct 15, 2012 · 4 comments

Projects

None yet

1 participant

Owner

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.

@ghost
ghost commented Oct 15, 2012

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

Owner

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.

@ghost
ghost commented Oct 15, 2012

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
ghost commented Nov 10, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment