From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: goswin-v-b@web.de
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Bug? Constraints get ignored in methods
Date: Mon, 06 Apr 2009 13:30:54 +0900 (JST) [thread overview]
Message-ID: <20090406.133054.00414260.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <874ox5jw6o.fsf@frosties.localdomain>
From: Goswin von Brederlow <goswin-v-b@web.de>
> > If you really want to stick to methods only (because of library
> > design, for instance), then a clever trick is to use a coercion
> > methods:
> >
> > class virtual base_type =
> > object (self)
> > val mutable virtual next : base_type option
>
> Why is next virtual here? Doesn't that require that anyone inheriting
> base_type has to define their own version of next? Seems like needless
> duplication.
No real reason. Just that you class type contained such field, so I
pasted it it the least effecting way. But since no method inside
base_type accesses it, I agree that it seems better not to put it
there.
> > method virtual set_next_base : base_type option -> unit
> > method as_base = (self :> base_type)
> > method set_next : 'a. <as_base : base_type; ..> as 'a -> unit =
> > fun x -> self#set_next_base x#as_base
> > end
A small typo in the above. Like in the function example it should be
fun x -> self#set_next_base (Some x#as_base)
> This helps a lot. Nice little trick to go through an immediate object
> type.
Actually, the self coercion and the use of a non-abbreviated object
type are independent, but in general it is too heavy to use the second
without the first.
Jacques Garrigue
prev parent reply other threads:[~2009-04-06 4:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 22:05 Goswin von Brederlow
2009-03-31 23:01 ` [Caml-list] " Martin Jambon
2009-03-31 23:12 ` Martin Jambon
2009-03-31 23:52 ` Goswin von Brederlow
2009-04-01 0:08 ` Goswin von Brederlow
2009-04-01 11:41 ` Martin Jambon
2009-04-01 15:57 ` Goswin von Brederlow
2009-04-01 18:45 ` Martin Jambon
2009-04-01 1:24 ` Peng Zang
2009-04-01 3:25 ` Goswin von Brederlow
2009-04-02 8:39 ` Jacques GARRIGUE
2009-04-03 20:53 ` Goswin von Brederlow
2009-04-06 4:30 ` Jacques Garrigue [this message]
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=20090406.133054.00414260.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=goswin-v-b@web.de \
/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