caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Yotam Barnoy <yotambarnoy@gmail.com>,
	 Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Ocaml compiler documentation
Date: Thu, 03 Apr 2014 22:16:09 +0200	[thread overview]
Message-ID: <533DC189.5090206@frisch.fr> (raw)
In-Reply-To: <CAN6ygOks4OmN_1_9CoCwq5AsNgf+Sh=fKBNfC=1_cq2VuxP6dQ@mail.gmail.com>

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

  parent reply	other threads:[~2014-04-03 20:16 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 [this message]
2014-04-04  7:39           ` François Bobot
2014-04-14  6:12           ` Mark Shinwell
2014-04-14  7:44             ` Alain Frisch

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=533DC189.5090206@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --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).