From: mathew
Date: 2011-01-25T11:14:10+09:00
Subject: [ruby-core:34845] Re: [Ruby 1.9-Feature#4264] General type coercion protocol for Ruby
On Wed, Jan 19, 2011 at 15:53, Charles Oliver Nutter
wrote:
> They're not bad, but casting to me means something altogether
> different: treating a an object as a different type, while still
> referencing the same object.
Casting refers to treating a value as a value of a different type,
that's true; however, it may or may not reference the same storage
(object, memory or register) after casting.
Consider the C code
int i = 4;
float j = (float) i;
which depending on the machine architecture and compiler, could result
in the second variable referring to a different register, perhaps even
on a different processor.
Having said that, I prefer "convert_to" and "convert_from" because
"cast" in this sense is specialist jargon, and why use jargon when
it's not necessary?
mathew