caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "SooHyoung Oh" <shoh@duonix.com>
To: "Jacques Garrigue" <garrigue@kurims.kyoto-u.ac.jp>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] Weak type, Open type
Date: Tue, 6 Aug 2002 10:04:08 +0900	[thread overview]
Message-ID: <001e01c23ce5$2aaf8b00$fe00a8c0@hama> (raw)
In-Reply-To: <20020805183043B.garrigue@kurims.kyoto-u.ac.jp>

Thanks for you reply.
Fortunately, I'm using Ocaml 3.05 and polymophic method works well.
But coding as your comments on weak type makes an error. See followings.

> From: "SooHyoung Oh" <shoh@duonix.com>
>
> > While I've studying design pattern with ocaml,
> > I made the followding 3 classes (PART1):
> > (1) class virtual entry: base class
> > (2) class file: subclass of "entry" class
> > (3) class dir: subclass of "entry" class
> >
> > I made some code using these classes on top level and it's ok. (PART 2).
> > While I translate the top level code into new class definition (PART3),
it
> > makes some error.
> > The error message is on (PART 4).
> >
> > It seems that (PART2) is weak type and (PART 3) is open type.
>
> Not weak: file_list has a weak type variable, but it gets immediatly
> instanciated to entry; and add is really polymorphic.
>
> > [Q 1] Is (PART2) is correct? I don't know why it doesn't make type
error.
> Yes. What's wrong?
> Note that your #entry is meaningless, since it is immediatly
> instanciated to entry. You could as well write entry list from the
> beginning, or nothing at all.
>

The types of (PART2) are
    val file_list : _#entry list ref = {contents = []}
    val add : #entry -> unit = <fun>
After removing '#':
    val file_list : entry list ref = {contents = []}
    val add : _#entry -> unit = <fun>

Using "entry" instead of "#entry" produces the following:
    This expression has type
      file = < file_size : unit -> int; name : unit -> string >
    but is here used with type < dir_size : unit -> int; name : unit ->
string >
    Only the second object type has a method dir_size

[Deleted ...]


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2002-08-06  1:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05  7:10 SooHyoung Oh
2002-08-05  9:30 ` Jacques Garrigue
2002-08-06  1:04   ` SooHyoung Oh [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='001e01c23ce5$2aaf8b00$fe00a8c0@hama' \
    --to=shoh@duonix.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    /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).