This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: records



> Are you sure we're talking the same thing here? "generic" in Eiffel
> means like C++ templates - _One_ bit of code that can be expanded to
> work on multiple classes. "generic" in CLOS is dispatching on type to
> _multiple_ bits of code depending on type. Totally different issues.

A generic type has its own state and behaviour.  But you can't create
instances from this type.  Instead you must combine the generic type
with a concrete type (the parameter).  For example the scheme
`display' function is generic.  When you pass an integer type, it will
display this integer, when you pass it a string type, it will
display the string.

On the other hand we have polymorphism.  Polymorphism means that a
type derives from a super-type.  So at run-time a instance has more
than one type and you can pass it to functions that require on of its
super-types.

In other words: polymorphism means that one bit of code can be
expanded to work on multiple classes by using interitance.  And
genericity means that the generic type dispatches on the type
of its parameter (or parameters).


> neither generics nor inheritance, yet it is possible to support both
> without extending the language.

(+ 1 2)
(+ 1.0 2.0)

The function `+' is generic.


> genericity in the Eiffel sense is a non-issue in scheme because it is
> not statically typed. Only static typed languages care about this.

I think it's the other way round.  You can't support inheritance
without a explicit type system. (*)


> > Eiffel supports inheritance *and* (as a special
> > case) a generic type so that it is not necessary to emulate it.
> 
> Not sure what you mean by Eiffel's special case.

Eiffel supports only unconstrained genericity, see his stack example
in OOSC.  So it is not necessary to create a empty class to derive your
parameter from.


Jost
(*) I like the type system that bigloo has.  I think it integrates nicely into
    the scheme world.  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]