Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Julian Assange <proff@iq.org>, caml-list@inria.fr
Subject: Re: list of objects
Date: Tue, 3 Oct 2000 11:53:04 +0200	[thread overview]
Message-ID: <20001003115304.56543@pauillac.inria.fr> (raw)
In-Reply-To: <wxaecnw63g.fsf@foo.iq.org>; from Julian Assange on Tue, Oct 03, 2000 at 03:38:59AM +1100

Your approach looks reasonable.  As for your question:

> let sig_list = [new plain; new simple] 
> On compilation, this produces:
>   The type of this expression, '_a Sigs.plain list,
>   contains type variables that cannot be generalized
> However sending the exact same code to the top level,
> produces:
> val sig_list : '_a Sigs.plain list = [<obj>; <obj>]
> Works just fine! What gives?

The '_a is a non-generalized type variable, i.e. an unknown type that
will be determined later at first use.  (See the FAQ
http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html for more detailed
explanations.)

For separately-compiled units, the notion of "first use" is unclear,
since the unit can be referenced by several other separately-compiled
units, which could each instantiate the unknown type in different
ways.  So, to keep things simple, the compiler requires that no
non-generalized type variables remain in the types inferred for
definitions of a compilation unit.

Thus, you need to put either a .mli file giving the type you want for
sig_list, or a type constraint on the definition of sig_list:
        let sig_list = ([new plain; new simple] : t Sigs.plain list)
with the type you want for "t".

Hope this helps,

- Xavier Leroy



      reply	other threads:[~2000-10-03 19:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-02 16:38 Julian Assange
2000-10-03  9:53 ` Xavier Leroy [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=20001003115304.56543@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=proff@iq.org \
    /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