caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christian RINDERKNECHT <rinderkn@hugo.int-evry.fr>
To: caml-list@inria.fr
Cc: Christian RINDERKNECHT <rinderkn@hugo.int-evry.fr>
Subject: [Q] Four micro-questions on objects and modules.
Date: Tue, 2 Nov 1999 14:09:52 +0100	[thread overview]
Message-ID: <19991102140952.A16438@jones.int-evry.fr> (raw)

Hello,

I have a few questions on objects and modules.

 1) Assume I compile m.ml made of: class c = object end
                        and m.mli: class c : object end

    Now:

            Objective Caml version 2.02
 
    # #load "m.cmo";;
    # let f = fun (x : #M.c) -> x;;
    val f : (#M.c as 'a) -> 'a = <fun>

    OK. What strikes me is:

    # let g = fun (x : M.c) -> x;;
    val g : M.c -> M.c = <fun>

    What is the difference between f and g? If the type of g is
    equivalent to #M.c -> #M.c, then according to the manual (#-types)
    there is a difference, isn'it?

    Moreover, I tought "M.c" was not syntactically correct when "c"
    is a class (hence the "#" symbol)... 


 2) What is the semantics of the syntactic productions
    (http://caml.inria.fr/ocaml/htmlman/node6.5.html):
 
    typexpr : typexpr # class-path
            | ( typexpr {, typexpr}) # class-path


 3) Would it be possible to allow the "include" feature in class
    types? 


 4) With values one can equivalently write:

    # let (h : unit -> unit) = fun x -> x;;
    val h : unit -> unit = <fun>

    or

    # let h = ((fun x -> x) : unit -> unit);;
    val h : unit -> unit = <fun>

    I prefer the former when the function expression is big and I don't
    want my eyes to read it only in order to find the type annotation
    at the end.

    For the same sake, I think it would be consistent and useful to
    allow class types, module types to qualify directly the module
    names and the class names: 

    # module (M : S) = struct (* lot of stuff here *) end;;
             ^
    Not a Syntax error!

    and

    # class (x : ct) = object (* lot of stuff here *) end;;     
            ^
    Not a Syntax error!

    ...and the same for method and value instances.


Best regards,

-- 

Christian

-----------------------------------------------------------------------
Christian Rinderknecht                     Phone +33 (0)1 60 76 44 43
Institut National des Télécommunications   Fax   +33 (0)1 60 76 47 11
Département Logiciels Réseaux (LOR)        WWW
9, Rue Charles Fourier, F-91011 Évry Cedex



             reply	other threads:[~1999-11-03 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-02 13:09 Christian RINDERKNECHT [this message]
1999-11-03 21:40 ` Jerome Vouillon
1999-11-07 10:37   ` Christian RINDERKNECHT

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=19991102140952.A16438@jones.int-evry.fr \
    --to=rinderkn@hugo.int-evry.fr \
    --cc=caml-list@inria.fr \
    /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).