[bitc-dev] Objects in BitC
Jørgen Hermanrud Fjeld
jhf at hex.no
Sat Feb 12 10:26:18 EST 2005
On Sat, Feb 12, 2005 at 08:36:38AM -0500, Jonathan S. Shapiro wrote:
> In short, most of the current uses of subclassing are either (a) bad
> idioms, or (b) good idioms overlayed on the wrong mechanism. BitC takes
> the position that most languages have erred by confusing interface types
> with object implementations. What we want is the ability to define
> something like Java interfaces, whose type is a set of ( method-name,
> signature ) pairs.
I assume you mean something like ML modules, because signatures are
independent of the module, modules just group them, like you describe,
while java interfaces has signatures that are relative to the interface
> ** BitC Interfaces
> BitC will have a form DEFINTERFACE:
> (definterface stream
> get : (fn () char)
> put : (fn (char) ())
> ... )
> At present, an interface will consist exclusively of functions. We *may*
> augment this in the future to include arbitrary deep-frozen constants.
> Interfaces may extend other interfaces:
> (definterface suptype
> (extends supertype)
> ... new methods ...)
Such that extends is reuse of function signatures?
> The major open question on DEFINTERFACE is whether we should provide an
> extra level of indirection to reduce space consumption. That is, should
> an interface instance be a structure whose members are closed over
> state, or should it be a pair of pointers (state, real-method-structure)
> [i.e. vtable like] with compiler support? I would be very interested in
> opinions on this question.
But if state is produced by invoking some function in the interface,
then the other functions that do something useful would take explicit
parameters, and you would have modules as found in ML-like languages.
If I imagine ML-like modules with existential and hidden types, which
represent the state, is that understanding somewhat on the right track?
If yes, this hints at a type system similar to GADTS by Peyton Jones.
> (define (extensible-plus x:'a y:'b)
> (typecase (tuple a b)
> ... dispatch on legal argument type pairs ...))
> Note that there has been a revision to the specification of typecase:
> the right hand sides are not required to evaluate to expressions of the
> same type.
So extensible-plus is universally quantified over 'a and 'b, and there
exists a run-time representation of types such that at run-time the
typecase can be evaluated, and there is no compile time checking that
uses of extensible plus are type correct, but a run-time exception will
always be thrown if extensible-plus is used incorrectly?
Or is extensible-plus quantified over a restricted set of types, to
facilitate compile time checking, and there is a run-time evaluation of
And are there compile time optimizations of typecase?
If the quantification of extensible-plus is expressed in the type
system, then type classes  could express that, and to optimize the
run-time representation of types and the compilation of typecase,
when the constraints are present at compile time, the concept of
flows [2 Sec.9] from extensional polymorphism could be useful.
 Mark P. Jones, 1995
Functional Programming with Overloading and Higher-Order Polymorphism
 Jun Furuse, 2002
Extensional Polymorphism: Theory and Application
Sincerely | Homepage:
Jørgen | http://www.hex.no/jhf
| Public GPG key:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.coyotos.org/pipermail/bitc-dev/attachments/20050212/71d7eb52/attachment.bin
More information about the bitc-dev