caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Patrick M Doane <patrick@watson.org>
To: Brian Rogoff <bpr@best.com>
Cc: "Krishnaswami, Neel" <neelk@cswcasa.com>, caml-list@inria.fr
Subject: Re: "Re: [Caml-list] A G'Caml question" + additional info
Date: Wed, 11 Jul 2001 23:15:57 -0400 (EDT)	[thread overview]
Message-ID: <Pine.BSF.3.96.1010711230056.26505A-100000@fledge.watson.org> (raw)
In-Reply-To: <Pine.BSF.4.21.0107110903260.7564-100000@shell5.ba.best.com>

On Wed, 11 Jul 2001, Brian Rogoff wrote:

> On Wed, 11 Jul 2001, Krishnaswami, Neel wrote:
> > Sven [mailto:luther@dpt-info.u-strasbg.fr] wrote:
> > > On Tue, Jul 10, 2001 at 02:21:02PM -0400, Krishnaswami, Neel wrote:
> > > > 
> > > > Can you describe how I'd write something like the show function in 
> > > > Haskell, or the print-object generic function in Dylan? I've looked
> > > > at the G'Caml documentation, and it doesn't look like it's possible
> > > > to extend a generic function with new branches.
> > > 
> > > i think they are speacking about an extension to g'caml that 
> > > would use the include keyword and permit such extension.
> > > Please read the previous mails about this thread.
> > 
> > Ah, I misunderstood, then. I thought the claim was that include 
> > wouldn't be included, but that it wasn't necessary. 
> 
> No. The discussion is about whether the proposed include feature is
> sufficient. My original concerns had to do with modeling recursive
> generics in such a way that they can be extended (hence my question about
> a form of open recursion) and I think Patrick was proposing something 
> like dynamic binding (Patrick?). 

Not quite dynamic binding... I'd still like everything to be resolved
statically.  The thoughts I initially had were:

  1) Link time analysis once all types are known.  This isn't suitable
for all applications and is also much harder to implement, but still an
option.

  2) Specialized syntax to re-analyze the body of a derived generic to
avoid "cut and paste" polymorphism (I like that term Max!).  Eventually, I
realized this is present through the functor system.

To really make me happy, I'd like to be able to use functors and generics
without having any performance penalty for cases when it matters.  I know
this can lead to code bloat in general, but the C++ community is certainly
moving along just fine with it (and continuing to make improvements).
Maybe some options to the compiler to control this behavior would be
useful.

> I've managed to convince myself that once generics play with modules and
> functors, include will give me enough rope (to hang myself with :) for
> now. Still, it is different from type classes and CLOS/Dylan generics, so 
> read the papers, the mails by Jun Furuse on include, and start kicking
> those tires! 

It's definitely sufficient.  I think we'll still see a large number of
messages from people being confused by the lack of dynamic binding, but
that's okay -- the functor approach should be easier to understand/debug.

So here's another thought about G'caml.  Suppose we have two record types
like this:

type t1 = {
  t1_field: int
};

type t2 = {
  t2_field: int
};

The field names have to be unique to be able to access them, but we can
"share" the field name through a generic:

generic get_field = case
  | t1 -> int => fun x -> x.t1_field
  | t2 -> int => fun x -> x.t2_field

Any hope for a compiler to auto-generate these declarations and provide a
syntax similar to dot notation?

Patrick


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-07-12  3:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-11 14:30 Krishnaswami, Neel
2001-07-11 16:22 ` Brian Rogoff
2001-07-11 16:35   ` Bruce Hoult
2001-07-11 19:12     ` Markus Mottl
2001-07-12  3:15   ` Patrick M Doane [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-16 18:24 John R Harrison
2001-07-10 18:21 Krishnaswami, Neel
2001-07-11  6:09 ` Sven
     [not found] <3B3D503C.E91DDE34@ozemail.com.au>
2001-06-30 16:01 ` Patrick M Doane
2001-06-30 20:59   ` Brian Rogoff
2001-07-01  5:32     ` Patrick M Doane
2001-07-02 15:55       ` Brian Rogoff
2001-07-10 18:08         ` Patrick M Doane
     [not found] <3B3BB6EC.3DEB6CBF@ozemail.com.au>
2001-06-29  4:18 ` Patrick M Doane
2001-06-20  3:16 [Caml-list] A G'Caml question Brian Rogoff
2001-06-25 17:11 ` "Re: [Caml-list] A G'Caml question" + additional info Jun Furuse
2001-06-28  2:21   ` Patrick M Doane
2001-06-28  4:40     ` Brian Rogoff

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=Pine.BSF.3.96.1010711230056.26505A-100000@fledge.watson.org \
    --to=patrick@watson.org \
    --cc=bpr@best.com \
    --cc=caml-list@inria.fr \
    --cc=neelk@cswcasa.com \
    /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;
as well as URLs for NNTP newsgroup(s).