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.
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
On Wed, May 19, 2004 at 12:15:15AM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
"type cast" is free afaics.
but the definition of cast is to change the type. so type cast may be redundand but not free. did you look at the links i posted. people use the term type casting when they mean any kind of casting. hence "type casting" already has a generic meaning.
when trying to coin a new term, we need to make sure not to use one that already has a meaning, and also be specific if possible.
typeonly cast?
"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).
but that's exactly what seems to happen:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
type of the variable is changed. of course it does not change the original variable but the input to the assignment of the result.
but that is true for any cast.
greetings, martin.
"type constriction" maybe? It's mainly what it's used for... :)
/ Mirar
Previous text:
2004-05-19 09:40: Subject: Re: Suggestions to manual
On Wed, May 19, 2004 at 12:15:15AM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
"type cast" is free afaics.
but the definition of cast is to change the type. so type cast may be redundand but not free. did you look at the links i posted. people use the term type casting when they mean any kind of casting. hence "type casting" already has a generic meaning.
when trying to coin a new term, we need to make sure not to use one that already has a meaning, and also be specific if possible.
typeonly cast?
"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).
but that's exactly what seems to happen:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
type of the variable is changed. of course it does not change the original variable but the input to the assignment of the result.
but that is true for any cast.
greetings, martin.
/ Brevbäraren
but that's exactly what seems to happen:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
type of the variable is changed.
No, the type of the _value_ fetched from the variable is changed. The same happens if there is no variable at all:
typeof(3);
(1) Result: int(3..3)
typeof([int]3);
(2) Result: int
All casts in Pike operate on values, not variables.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-05-19 09:40: Subject: Re: Suggestions to manual
On Wed, May 19, 2004 at 12:15:15AM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
"type cast" is free afaics.
but the definition of cast is to change the type. so type cast may be redundand but not free. did you look at the links i posted. people use the term type casting when they mean any kind of casting. hence "type casting" already has a generic meaning.
when trying to coin a new term, we need to make sure not to use one that already has a meaning, and also be specific if possible.
typeonly cast?
"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).
but that's exactly what seems to happen:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
type of the variable is changed. of course it does not change the original variable but the input to the assignment of the result.
but that is true for any cast.
greetings, martin.
/ Brevbäraren
but the definition of cast is to change the type.
Of the value. The important part is that it's the value that changes. It's not strange that strongly typed languages blur that distinction. Especially C, which doesn't have any type info at all in values.
did you look at the links i posted.
No, sorry, I missed those. I've looked at them now and can't find the term "type cast" there either. But you're right as far as types having an important role in both cast varieties.
people use the term type casting when they mean any kind of casting. hence "type casting" already has a generic meaning.
You keep saying that, but I personally don't have that experience and so far haven't seen any evidence of that use. Anyway, I guess I'll just have to take your word for that it is so in your circles.
Maybe "type assertion" instead? That's fairly precisely what it's about.
/ Martin Stjernholm, Roxen IS
Previous text:
2004-05-19 09:40: Subject: Re: Suggestions to manual
On Wed, May 19, 2004 at 12:15:15AM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
"type cast" is free afaics.
but the definition of cast is to change the type. so type cast may be redundand but not free. did you look at the links i posted. people use the term type casting when they mean any kind of casting. hence "type casting" already has a generic meaning.
when trying to coin a new term, we need to make sure not to use one that already has a meaning, and also be specific if possible.
typeonly cast?
"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).
but that's exactly what seems to happen:
mixed m; typeof(m);
(1) Result: mixed
typeof([int] m);
(2) Result: int
type of the variable is changed. of course it does not change the original variable but the input to the assignment of the result.
but that is true for any cast.
greetings, martin.
/ Brevbäraren
pike-devel@lists.lysator.liu.se