caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Mark Shinwell <mshinwell@janestreet.com>
Cc: Yotam Barnoy <yotambarnoy@gmail.com>,
	 Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Ocaml compiler documentation
Date: Mon, 14 Apr 2014 09:44:01 +0200	[thread overview]
Message-ID: <534B91C1.1050508@frisch.fr> (raw)
In-Reply-To: <CAM3Ki76iPhcNdVDa-jr1TidgHFT7p-j1DDiC+vMTe+Fg6UBo3Q@mail.gmail.com>

On 04/14/2014 08:12 AM, Mark Shinwell wrote:
> Alain, I think "open!" does affect the "unused open" warning.  (This
> is a useful feature when you are trying to establish a consistent set
> of in-scope names, a good example being Core's "open
> Int.Replace_polymorphic_compare", which you may well want to have even
> if your file doesn't happen to use a comparison operator right now.)

Indeed, you're right!  (And this is amusing, considering that I 
implemented both warnings...)

I've feel slightly unhappy about using "open!" for two unrelated things, 
but since you consider this behavior to be useful, I won't touch it 
unless someone else has a strong opinion about it.

-- Alain

>
> I checked this using the following test program and "-w +a".
>
> module M = struct
>    let foo x = x + 42
> end
> open! M         (or "open")
>
> Mark
>
> On 3 April 2014 21:16, Alain Frisch <alain@frisch.fr> wrote:
>> On 4/3/2014 4:48 AM, Yotam Barnoy wrote:
>>>
>>> Ok I think a good place to start a tour of the compiler is in
>>> parsing/parsetree.mli. This file is actually very well documented, with
>>> terse but effective examples of almost every constructor and type.
>>
>>
>> Good idea indeed, especially that the Parsetree will gain in the next
>> release a more important status, with -ppx rewriters, annotations and
>> attributes.
>>
>>
>>> I had to refer to the OCaml manual for a few of the corner cases. For
>>> example, I didn't know about the #class type shortcut. I think a few
>>> comments explaining the more obscure facets of the language could be
>>> helpful.
>>
>>
>> Generally speaking, a good place to document the language is the user
>> manual.  Don't hesitate to suggest patches to the manual as well!  (The
>> source code is in the same repository:
>> http://caml.inria.fr/cgi-bin/viewvc.cgi/ocamldoc/trunk/ ).
>>
>> That said, for the specific case of Parsetree, it might indeed be useful to
>> give some hints about rare language features in the source code as well.
>>
>>
>>> 1. What is the difference between an extension and an attribute? From
>>> what I understand, they are both means of integrating additional
>>> metadata into the AST that can then be parsed by implementations of the
>>> ast-mapper, but why are there 2 mechanisms?
>>
>>
>> An extension is something which will be rejected by the type-checker. It is
>> placeholder for "sub-languages", to be processed by -ppx filters.
>>
>> An attribute is indeed a way to integrate meta-data into a (hopefully) valid
>> AST.  They could be used by -ppx filters to drive their behavior, by
>> external tools to get some extra information (e.g. Bisect annotations), and
>> they are propagated to the typedtreed, and hence to .cmt/.cmti files, again
>> for external tools which read those files.  They are also kepts on some
>> kinds of declarations (e.g. values and types) so that they are part of the
>> Types structures, and hence found in .cmi files as well.  The compiler also
>> give a built-in meaning to some attributes (to be documented).
>>
>> Some more information:
>> http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/trunk/experimental/frisch/extension_points.txt?revision=HEAD&view=markup
>>
>>
>>> 3. line 684: what is the purpose of the override flag on Pstr_open? It's
>>> not explained by the comment.
>>
>>
>> The override flag (i.e. "open!" as opposed to "open") is used to silence the
>> new warning which signals when an open statement shadows an existing
>> identifier which is later used.   (It does not affect the 'unused open'
>> warning.)
>>
>>
>>> 4. The toplevel phrases are not clear. What is the purpose of Ptop_dir
>>> on line 721?
>>
>>
>> Those are #-directives understood by the toplevel (#use, #load, etc).
>>
>>
>> -- Alain
>>
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


      reply	other threads:[~2014-04-14  7:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31 15:39 Yotam Barnoy
2014-03-31 17:06 ` Milan Stanojević
2014-03-31 17:51   ` Yotam Barnoy
2014-04-01 10:03     ` Mark Shinwell
2014-04-03  2:48       ` Yotam Barnoy
2014-04-03  6:18         ` Mark Shinwell
2014-04-03  8:42         ` Jeremy Yallop
2014-04-03  9:05         ` David Allsopp
2014-04-03 10:20           ` Simon Cruanes
2014-04-03 10:46             ` David Allsopp
2014-04-03 18:17               ` Yotam Barnoy
2014-04-03  9:10         ` Gabriel Scherer
2014-04-03 20:16         ` Alain Frisch
2014-04-04  7:39           ` François Bobot
2014-04-14  6:12           ` Mark Shinwell
2014-04-14  7:44             ` Alain Frisch [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=534B91C1.1050508@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=mshinwell@janestreet.com \
    --cc=yotambarnoy@gmail.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).