Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Matt Gushee <matt@gushee.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic class types?
Date: Sat, 22 Oct 2005 18:52:48 +1000	[thread overview]
Message-ID: <1129971168.4139.15.camel@rosella> (raw)
In-Reply-To: <4359D3DC.5060307@gushee.net>

On Fri, 2005-10-21 at 23:53 -0600, Matt Gushee wrote:

> Interesting. I'm not sure a hierarchical model would apply here--the
> basic data model I'm trying to support is a graph rather than a tree.
> Think "visual RDF editor" ... though I'm not trying to tie this thing
> directly to RDF per se, it's conceptually pretty close. But I'd still be
> interested in how you did that. Is your Python code available somewhere?

No sorry. The reason for a tree is that this is the model
of containment. Notebooks contain windows .. vertically paned
windows contain windows .. the Screen contains top level windows..
a network has many screens (I used to have two monitors, I could move
things from one to the other with drag-n-drop).

The containment relation uses a Tree widget instead of a linear
'toolbar'. Allows the user to group and regroup the 'card'
content in interesting ways.

> > is wrong. on the contrary! The display manager MUST NOT
> > know anything about the content. All you really need is
> > a single 'render' method with a 'surface' argument,
> 
> Maybe I didn't make myself clear. 

I think you did -- in any case Jacques Garrigue actually factored
your model by removing the contents, I think what he did is
correct.

[oo subtypes]

> I thought that's what I was doing.

In some language of Barry Jay, you can actually do that:
the parameter to a class is how you extend it, using
open recursion. It's very nice -- if you instantiate the parameter
to 'ground' the class becomes closed like with Java 'final'.

>  Not well, obviously, hence my inquiry
> to the list. If you have time, I'd like to hear more about this ... what
> exactly do you mean by OO style subtyping? I've heard "subtyping is not
> inheritance" about a thousand times ... but there's not much
> documentation on how to do it right in OCaml, and unfortunately I don't
> have enough theoretical background to figure it out on my own.

In Ocaml a class D is a subtype of B if D has 'at least all
the methods of B'.  Inheritance may be convenient way to make
this happen but it isn't essential.

It's clear why this works: the interfaces are the same for B and
D if you 'ignore some of the methods of D'. So any algorithm
that works for a B will work for a D.

[This isn't quite right as I'm sure someone will point out,
but it is a good first approximation :]

> > class type card = object
> > [ .... ]
> 
> > and another type
> >
> > class type ['a] data_card = object
> >   inherit card
> 
> Aha! Inheritance in class types ... I wasn't aware that you could do
> that (actually I think I may have done it once a couple of years ago,
> but if I did I must have forgotten about it).

It isn't inheritance.. its just a macro that pastes in
the inherited signature (more or less :) Saves writing,
nothing more.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2005-10-22  8:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21 20:44 Matt Gushee
2005-10-22  1:51 ` [Caml-list] " skaller
2005-10-22  5:53   ` Matt Gushee
2005-10-22  8:52     ` skaller [this message]
2005-10-22  1:59 ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1129971168.4139.15.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=matt@gushee.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox