Types, types: static vs. dynamic -- classification 
Author Message
 Types, types: static vs. dynamic -- classification


             Dynamically typed is often refered to poly-
             morphism.

And wrongly so.  SML, for example, is statically typed and uses a
polymorphic type system.   These two things are not the same.

--
-Matthias



Fri, 06 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

I lost the trace of the thread of C++ static typing vs.
Smalltalk dynamic typing. The debate is interesting,
but we cannot have any conclusion if we focus on the
terminology only.

There are a number of different ways to define typing.
I cannot tell which one should be the standard. Each
langauge has its own definition. The difference is
especially remarkable between dynamic languages like
SmallTalk and static languages C++ and Eiffel. Therefore,
do not pay attention to the word itself, instead, focus
on the definition associated with the word.

The following list is helpful for you to identify
which kind of type system a language has:

1. Type vs. typeless

   * Does a language provide types?

     Prototype languages like Self do not have type at
     all. Objects are created by cloning exisiting
     objects.

   For languages have types, we have:

   1.1. Dynamic typing system vs. static typing system

        * Can type (subtype) be defined at run-time?
          or, is the class hierarchy dynamic?

        For dynamic typing system, we further have:

        1.1.1. Dynamic typing vs. static typing

               * Can we change the state of a type
                 at run-time? Or, can we add/delete
                 methods or instance variables to/from
                 an existing type dynamically?

                 Some dynamic typing system does not
                 allow the state change of a type once
                 the type is created.

2. Typed vs. untyped

   * Does a name declaration need the specification of
     its type?

     SmallTalk is an untyped language because variables
     are untyped.

   Further, for typed language, we have:

   2.1. Dynamically typed vs. statically typed

        * Can a declared name assumes different types
          in a given range at run-time?

          C++ is dynamically typed in terms of pointer
          declarations. Eiffel is dynamically typed in
          terms of non-primitive variable declaration.
          Dynamically typed is often refered to poly-
          morphism.

          Untyped lnaguage is an special case (extreme)
          of dynamically typed langauges.

3. Static type checking vs. dynamic type checking

   * Does a language needs dynamic type checking to ensure
     type safe?

4. Type safe vs. unsafe

   * Can a language ensure that all type errors should be
     detected?

   For type safe languages, we have:

   4.1. Static type safe vs. dynamic type safe

        * Can a language guarantee no run-time error
          (after comiplation)?

Two important notes:

(1) Languages that requires run-time type check can be
    statically safe;

(2) Dynamic typing system with static typing is the maximum
    benefit point  between statics and dynamics.

David



Fri, 06 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:


L. Shang) writes:

>         Dynamically typed is often refered to poly-
>         morphism.

> And wrongly so.  SML, for example, is statically typed and uses a
> polymorphic type system.   These two things are not the same.

As I said, each type system or particular language has its
own definition. I am not going to argue with you what name
should be used for what definition.

The majority of static OO langauges including C++, Eiffel, Sather,
Beta, Modula-3, Ada95, etc, use polymorphism in the case which
I described as dynamically typed variables or parameters.

David



Mon, 09 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:
(David L. Shang) writes:




Quote:
|> L. Shang) writes:

|> >
|> >           Dynamically typed is often refered to poly-
|> >           morphism.
|> >
|> > And wrongly so.  SML, for example, is statically typed and uses a
|> > polymorphic type system.   These two things are not the same.

|> As I said, each type system or particular language has its
|> own definition. I am not going to argue with you what name
|> should be used for what definition.

|> The majority of static OO langauges including C++, Eiffel, Sather,
|> Beta, Modula-3, Ada95, etc, use polymorphism in the case which
|> I described as dynamically typed variables or parameters.

Actually, C++ has both static and dynamic polymorphism.  The static
polymorphism is implemented using templates, and the dynamic using
virtual functions.  Thus, for example, the STL function ``sort'' is
polymorphic, although the polymorphism is resolved at compile time
(staticly).

On the other hand, it is true that in general, when a C++ program
speaks of polymorphism, or a polymorphic object, he is almost always
speaking of dynamic polymorphism.
--

GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                              -- Beratung in industrieller Datenverarbeitung



Fri, 13 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:

>As I said, each type system or particular language has its
>own definition. I am not going to argue with you what name
>should be used for what definition.

Huzzah!
Meaning is TYRANNY - distinction IS discrimination.
We will never KNOW true freedom until we EACH speak our
OWN TRUE LANGUAGE.   Burn all dictionaries NOW.


---|  Computer Systems Engineer          University of {*filter*}ia  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  Box 449 Health Science Center    C{*filter*}tesville,VA 22908  |---
 [ "The grass is always greener, except at t=0" - Stan Kelly-Bootle ]



Sat, 14 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:
(Steven D. Majewski) writes:


> >As I said, each type system or particular language has its
> >own definition. I am not going to argue with you what name
> >should be used for what definition.

> Huzzah!
> Meaning is TYRANNY - distinction IS discrimination.
> We will never KNOW true freedom until we EACH speak our
> OWN TRUE LANGUAGE.   Burn all dictionaries NOW.

Steven,

If you can present a set of standard names that can please
everyone, please do so.

My inability to set up a standardized terminology in this
very particular area is not responsible for people who are
going to burn all dictionaries.

David



Tue, 17 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:
(Steven D. Majewski) writes:


> >As I said, each type system or particular language has its
> >own definition. I am not going to argue with you what name
> >should be used for what definition.

> Huzzah!
> Meaning is TYRANNY - distinction IS discrimination.
> We will never KNOW true freedom until we EACH speak our
> OWN TRUE LANGUAGE.   Burn all dictionaries NOW.

Steven,

If you can present a set of standard names that can please
everyone, please do so.

My inability to set up a standardized terminology in this
very particular area is not responsible for people who are
going to burn all dictionaries.

David



Tue, 17 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification
Kanze US/ESC 60/3/141 #40763) said:

    James> Actually, C++ has both static and dynamic polymorphism.
    James> The static polymorphism is implemented using templates, and
    James> the dynamic using virtual functions.  Thus, for example,
    James> the STL function ``sort'' is polymorphic, although the
    James> polymorphism is resolved at compile time (staticly).

Isn't function overloading a form of static polymorphism?

--
Anil

___________________________________________________________________________
Anil K Vijendran                    USL Box 43007, Lafayette, LA 70504-3007



Fri, 20 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:

>Isn't function overloading a form of static polymorphism?

No. Function overloading is just a way of forming a
function name implicitly from the given name plus the
types of the parameters.

Each overloaded function could be given a unique function
name disregarding the parameters.

Any specific call to an overloaded function can only call
the one function with that name and those parameters. There
is no way subsequently to call a different function from that
same lexical position.

--

(503) 264-9309, FAX: (503) 264-3375

"Poor design is a major culprit in the software crisis...
..Beyond the tenets of structured programming, few accepted...
standards stipulate what software systems should be like [in] detail..."
-IEEE Computer, August 1995, Bruce W. Weide



Fri, 20 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification


Quote:

> Isn't function overloading a form of static polymorphism?


Quote:
> No.  [...]  Any specific call to an overloaded function can only
> call the one function with that name and those parameters. There is
> no way subsequently to call a different function from that same
> lexical position.

This is true in C++, where the overloading must be resolved at
compile-time, but it is not necessarily true in general.  In a
language where values are latently-typed, a given lexical occurrence
of an overloaded function may dispatch to different methods at
run-time depending on the values provided.

In fact, one could imagine rewriting a C++ virtual method invocation:

        object->message(args, ...)

as:

        message(object, args, ...)

where `message' is an overloaded function that gets resolved at
run-time based on the run-time type of `object'.  If the only object
allowed are objects derived from a specific base class, then this kind
of overloading is said to be "subtyping polymorphism" (which is what
C++ supports).  However, if the object types can be completely
unrelated, then this kind of overloading is said to support "ad-hoc
polymorphism".

So there is a point of view that says that overloading as implemented
in C++ *is* "static ad-hoc polymorphism" (to the degree that this
isn't a contradiction in terms).

-thant



Fri, 20 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:



>> Isn't function overloading a form of static polymorphism?


>> No.  [...]  Any specific call to an overloaded function can only
>> call the one function with that name and those parameters. There is
>> no way subsequently to call a different function from that same
>> lexical position.

>This is true in C++, where the overloading must be resolved at
>compile-time, but it is not necessarily true in general...

Right. Good point. We have to be careful with what is left
unsaid. I was assuming C++ or Ada-like overloading. (Don't
know about Ada-9x either.)

Certainly, CLOS and Dylan among others provide Generic Functions
which are usually categorized as "multi-argument dispatch" rather
than "overloading". Yes, this is a kind of "overloading" that
is polymorphic.

--

(503) 264-9309, FAX: (503) 264-3375

"Poor design is a major culprit in the software crisis...
..Beyond the tenets of structured programming, few accepted...
standards stipulate what software systems should be like [in] detail..."
-IEEE Computer, August 1995, Bruce W. Weide



Fri, 20 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:
>>> On 2 Oct 1995 15:13:21 GMT, "Patrick D. Logan"



Anil> Isn't function overloading a form of static polymorphism?

Not at all; overloading is a property of interfaces, while
polymorphism/genericity is instead a property of implementations.

On the other hand there is a link between the two: static overloading
can give rise to static polymorphism/genericity, just as dynamic
polymorphism/genericity is a possible consequence of dynamic
binding/runtime overload resolution.

Genericity happens if all function/operator calls within an
implementation are overloaded with respect to more than one "type".

Patrick> No. Function overloading is just a way of forming a
Patrick> function name implicitly from the given name plus the
Patrick> types of the parameters.

This is one of those cases in which you mistake implementation for
concepts, and clumsily too. What you describe is not overloading, which
is a conceptual property of interfaces, but just *one* possible
_implementation_ of overloading, and not even the most elegant. In
effect, Stroustrup wrote that he used it in _implementing_ C++'s
overloading only because one of the goals of C++ was to be usable with
stock linkers.



Sat, 21 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification

Quote:

> Anil> Isn't function overloading a form of static polymorphism?

> Not at all; overloading is a property of interfaces, while
> polymorphism/genericity is instead a property of implementations.

> On the other hand there is a link between the two: static overloading
> can give rise to static polymorphism/genericity, just as dynamic
> polymorphism/genericity is a possible consequence of dynamic
> binding/runtime overload resolution.

I don't understand the distinction you are trying to make.  How would
one express ad-hoc polymorphism in a way that couldn't be considered a
form of overloading?

Thant Tessman



Sun, 22 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification


|> Kanze US/ESC 60/3/141 #40763) said:

|>     James> Actually, C++ has both static and dynamic polymorphism.
|>     James> The static polymorphism is implemented using templates, and
|>     James> the dynamic using virtual functions.  Thus, for example,
|>     James> the STL function ``sort'' is polymorphic, although the
|>     James> polymorphism is resolved at compile time (staticly).

|> Isn't function overloading a form of static polymorphism?

If you say so:-).  Polymorphism is one of those terms where everyone
seems to have their own definition.  I've always considered (C++'s)
function overloading as more a case of extended function names; the
parameter types are, in fact, considered as part of the name.  But
this is probably influenced by what I know about how compilers
actually implement function overloading (i.e.: name mangling).
--

GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                              -- Beratung in industrieller Datenverarbeitung



Sun, 22 Mar 1998 03:00:00 GMT  
 Types, types: static vs. dynamic -- classification


Anil> Isn't function overloading a form of static polymorphism?

pcg> Not at all; overloading is a property of interfaces, while
pcg> polymorphism/genericity is instead a property of implementations.

pcg> On the other hand there is a link between the two: static overloading
pcg> can give rise to static polymorphism/genericity, just as dynamic
pcg> polymorphism/genericity is a possible consequence of dynamic
pcg> binding/runtime overload resolution.

Thant> I don't understand the distinction you are trying to make.

It is a *consequence* of overloading. Now a consequence of X is not a
form of X, at least as I understand (not being a native english speaker)
the relationship denoted by "form". For example a consequence of
{*filter*} may be pregnancy, but I would not say that {*filter*} is a
form of pregnancy.

Let's consider (in a made up notation reminiscent of C++):

        struct cmplx { ... };

        float distance(float a,b)
        { return sqrt(b*b - a*a); }

        cmplx distance(cmplx a,b)
        { return sqrt(b*b - a*a); }

        struct number { ... virtual number sqrt() ... };
        struct float : number { ... number sqrt() { ... } ... }
        struct complex : number { ... number sqrt() { ... } ... }
        /* assume virtual operator "*" and blah blah ... */

        number gdistance(number a,b)
        { return number(b*b - a*a).sqrt(); }

Now: "distance" is an interface name associated to two distinct
implementations/bodies (association to be resolved at compiletime in the
case of most languages like C++); while gdistance is an interface name
associated with a single generic implementation/body. The implementation
is generic because all the operators/functions it uses, "*" and "sqrt",
are overloaded w.r.t. more than one type. Note that in this case we have
static genericity and not dynamic genericity, despite using "virtual",
as we have not used pointers.



Mon, 23 Mar 1998 03:00:00 GMT  
 
 [ 135 post ]  Go to page: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

 Relevant Pages 

1. Types, types: static vs. dynamic -- classification

2. Types, types: static vs. dynamic -- classification

3. Types, types: static vs. dynamic --

4. Flying With Python (Strong versus Weak Typing) [actually, Static vs Dynamic typing]

5. Static vs Dynamic Typing: Effects on Productivity?

6. Dynamic vs. static type checking

7. Static vs Dynamic Typing: Effects on Productivity?

8. Static vs Dynamic Typing: Effects on Productivity?

9. Static vs Dynamic Typing: Effects on Productivity?

10. Dynamic vs static typing: impact on modelling capabilities

11. static vs dynamic/soft typing

12. static vs. dynamic typing (again, again)

 

 
Powered by phpBB® Forum Software