the difference is than that [type] only changes the variable but not its value, whereas (type) changes both.
You're right that (type) changes both the value at runtime and the type at compile time, so talking about a "value cast" would strictly speaking only mention a subset of its behavior. However, [type] doesn't affect the variable at all, in as far as any is involved (and neither do (type)).
in other languages (see the c and java examples), the term "type cast" is used to describe the first case where where both variable and value are changed.
I've only taken a quick peek in the language specs, but C simply uses "cast", as do Java. C++ have the terms "dynamic cast", "static cast", "reinterpret cast" and "const cast" (C++ always has to be worst all the time, it seems). Anyway, "type cast" is free afaics.
"variable cast" might work.
That doesn't make sense at all to me. Sounds like an attempt to change the type stored in a variable, which isn't possible (except through inherits in some special cases).
/ Martin Stjernholm, Roxen IS
Previous text:
2004-05-18 16:09: Subject: Re: Suggestions to manual
i am changing the list, as this is not relevant for pike users.
On Tue, May 18, 2004 at 03:46:44PM +0200, Martin Stjernholm wrote:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
Only the type is changed, hence a type cast. A normal cast like (int) "1" changes the value, hence a value cast.
the difference is than that [type] only changes the variable but not its value, whereas (type) changes both.
in other languages (see the c and java examples), the term "type cast" is used to describe the first case where where both variable and value are changed.
hence i think it is a bad idea to use a different definition in pike. coining new terms is fine, but chaning existing ones will lead to confusion.
"variable cast" might work.
greetings, martin.
/ Brevbäraren