469,647 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Dynamic type checking

Whenever I read any C++ literature I find the words "C++ is statically type
checked".OK.Agreed.
Is there any language that supports "Dynamic type checking"?
In such a case any type can be assigned to any other type during compile
time?
Jul 22 '05 #1
3 1931

"Vinodh Kumar P" <th*************@yahoo.com> schrieb im Newsbeitrag
news:ca**********@news.mch.sbs.de...
Whenever I read any C++ literature I find the words "C++ is statically type checked".OK.Agreed.
Is there any language that supports "Dynamic type checking"?
In such a case any type can be assigned to any other type during compile time?


Maybe inheritance or cast-operators would do? I mean - what do you
expect when you assign a void* to a CMyClass?? See, you have to define
it to get what you want.
-Gernot
Jul 22 '05 #2
Vinodh Kumar P wrote:
Whenever I read any C++ literature I find the words "C++ is statically
type checked".OK.Agreed.
Is there any language that supports "Dynamic type checking"?
Most scripting languages do.
In such a case any type can be assigned to any other type during
compile time?


You variables might not even have a type at compile time since that type
can change at run-time. So if you assign a variable to another one,
that other variable changes its type accordingly.
Consider python:

x = 3 # x is an integer
y = "Hello world" # y is a string
x = y # now x is a string, too

In C++, a variable can never change its type. You can however use
polymorphism to get a more dynamic behaviour, within some limits.

Jul 22 '05 #3
Rolf Magnus wrote:
Vinodh Kumar P wrote:
Whenever I read any C++ literature I find the words "C++ is
statically type checked".OK.Agreed.
Is there any language that supports "Dynamic type checking"?


Most scripting languages do.
In such a case any type can be assigned to any other type during
compile time?


You variables might not even have a type at compile time since that
type can change at run-time. So if you assign a variable to another
one, that other variable changes its type accordingly.
Consider python:

x = 3 # x is an integer
y = "Hello world" # y is a string
x = y # now x is a string, too

In C++, a variable can never change its type. You can however use
polymorphism to get a more dynamic behaviour, within some limits.


You can implement a VB6- style variant class, which I'm doing now. Of course
on the inside you must use static type checking, but so does VB's variant.

variant x = 3; // it's an int
variant y = "hello"; // this one's a string
x = y; // now it's a string too

Mine so far supports that, and operator+, but I've got the basic framework
done and it will be easy to do the rest of the operators. I'll post it here
when I'm done.

- Pete
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by gao_bolin | last post: by
9 posts views Thread by Gibby Koldenhof | last post: by
4 posts views Thread by Mark Healey | last post: by
9 posts views Thread by pbd22 | last post: by
1 post views Thread by Samuel R. Neff | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.