Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Dynamic type checking

Reply
Thread Tools

Dynamic type checking

 
 
Vinodh Kumar P
Guest
Posts: n/a
 
      06-14-2004
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?


 
Reply With Quote
 
 
 
 
Gernot Frisch
Guest
Posts: n/a
 
      06-14-2004

"Vinodh Kumar P" <(E-Mail Removed)> schrieb im Newsbeitrag
news:cajcdl$pnf$(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      06-14-2004
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.

 
Reply With Quote
 
Pete C.
Guest
Posts: n/a
 
      06-14-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Hinting vs Type Checking and Preconditions Tom Bradford Python 4 03-10-2006 06:25 PM
Re: Type Hinting vs Type Checking and Preconditions Tom Bradford Python 3 03-09-2006 07:37 AM
RE: Type Hinting vs Type Checking and Preconditions Delaney, Timothy (Tim) Python 7 03-08-2006 05:32 PM
Checking a form input tag type works only for type text... not others...why? Randell D. Javascript 12 07-06-2005 07:51 PM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM



Advertisments