Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management
From: Isaac Gouy (igouy_at_yahoo.com)
Date: 07/09/04
- Next message: Matthias Blume: "Re: Universal iconic language - (was - Sanskrit as computer programming language)?"
- Previous message: Michael Jørgensen: "Re: Interview"
- Maybe in reply to: Thomas Gagne: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Next in thread: Jörn W. Janneck: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Jul 2004 09:03:18 -0700
"Thomas G. Marshall" <tgm2tothe10thpower@replacetextwithnumber.hotmail.com> wrote in message news:<2FkHc.14296$Xb4.12145@nwrdny02.gnilink.net>...
> > So, ad hoc polymorphism.
> >
> > void main(String[] args){
> > println( "my adhoc method call".function );
> > println( new Thread().function );
> > }
> >
> > abstract interface AdHoc {
> > String adhoc();
> > }
> >
> > <AdHoc T> String function(T obj){ return obj.adhoc; }
> >
> > class java.lang.String implements AdHoc;
> > String adhoc(String a){ return "String adhoc method"; }
> >
> > class java.lang.Thread implements AdHoc;
> > String adhoc(Thread a){ return "Thread adhoc method"; }
>
> This /still/ uses an interface to get around the inheritance issue. That's
> precisely the point.
The Nice example /does not inherit/ from some new reference type that
we decided to classify as an Interface rather than a Class.
The question was "And what of the polymorphism /without/ inheritance?"
In this example, String and Thread share the property "AdHoc"
/without/ having a common super-type. "AdHoc" is a property possessed
by some types - it's a Kind, not a Type.
void main(String[] args){
AdHoc a;
...
}
I:\Nice\Test\..\Test\Test.nice: line 2, column 4:
This abstract interface cannot be used as a type
> In a dynamic language, there is nothing tying the two together for poly-m to
> work.
Nothing apart from both having a common property - they respond to the
message "method". They are 'tied together' by an implicit protocol.
We've made the protocol explicit, without using inheritance.
> > I:\Nice\Test>java -jar adhoc.jar
> > String adhoc method
> > Thread adhoc method
> >
> > See "Using kinds to type partially-polymorphic methods"
> > http://www1.elsevier.com/gej-ng/31/29/23/132/23/25/75003.pdf
> >
> >
> > Shall we try a pure functional language?
> > (Note: "In a type class definition one gives a name to a set of
> > overloaded functions")
> >
> > Start = function 5 +++ function [1,2,3]
> >
> > function a = adhoc a
> >
> > class adhoc a :: a -> String
> >
> > instance adhoc Int
> > where adhoc a = "Int overloaded function \n"
> >
> > instance adhoc [a]
> > where adhoc a = "List overloaded function \n"
> >
> > I:\Clean\Test>adhoc
> > Int overloaded function
> > List overloaded function
- Next message: Matthias Blume: "Re: Universal iconic language - (was - Sanskrit as computer programming language)?"
- Previous message: Michael Jørgensen: "Re: Interview"
- Maybe in reply to: Thomas Gagne: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Next in thread: Jörn W. Janneck: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|