[bitc-dev] BitC 0.20: Objects in BitC
rick.richardson at gmail.com
Thu Mar 11 14:25:51 PST 2010
> I don't think it is fully implemented in the current implementation,
> but BitC already provides a mechanism for ad-hoc polymorphism over
> structures through the built-in "has-field" constraint. This takes the
To me, ad-hoc polymorphism is not as important as parametric polymorphism.
Though, it seems to me the method you describe is one that would constrain
set of types over which a generic function could be applied.
> What I am imagining is that we think of virtual functions as consisting of
> an "ordered union type". That is: a sequence of types of progressively
> decreasing desirability.
Go uses a similar concept since it disallows inheritance in favor of
aggregation. It implicitly forwards method calls of aggregated interfaces. I
find it a reasonable alternative to inheritance.
Note they only allow disjoint sets of methods to be included into an
interface. So there is no resolution order required. Unless the ordering
were explicit, I might find it annoying to debug large projects, if I had to
traipse through code to determine which function was being called.
I think what I am struggling with is the implicit vs. explicit object
> notion. So far as I can tell, the difference is that explicit objects
> instantiate their class's type variables, and in doing so, form a
> representation. Implicit objects instantiate *none* of their class's type
> variables, and thereby serve as constraints only, wherein the ability to
> instantiate an object of the appropriate class type (which is stateless and
> therefore costs nothing to instantiate) serves as witness of membership in
> the class relation.
IMO, the only advantage of explicit classes is found in languages which
don't have builtin garbage collection. The explicit nature of constructors
and (especially) destructors, better allows a programmer to babysit
resources. If BitC is intended to be GC optional, this might be a
compelling enough reason.
As a matter of taste, I don't care for them, but I see one benefit and no
real detriments that I can think of. My beef with objects is the rest of
the OO system, namely inheritance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the bitc-dev