Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Peter Zotov <whitequark@whitequark.org>
To: Jun Furuse <jun.furuse@gmail.com>
Cc: Alain Frisch <alain@frisch.fr>, caml-list <caml-list@inria.fr>,
	caml-list-request@inria.fr
Subject: Re: [Caml-list] [ANN] ppx_overload : ppx for user definable SML style overloading
Date: Tue, 14 Oct 2014 18:55:12 +0400	[thread overview]
Message-ID: <78874d6b72b958db5e74b9b21c18e8d2@whitequark.org> (raw)
In-Reply-To: <CAAoLEWsm1yH+BL9GwJKO6bLZOt9sC+zvZFK9yvB07rofafgt1w@mail.gmail.com>

On 2014-10-14 17:08, Jun Furuse wrote:
> I do not think the ppx cookies can help ppx_overload in toplevel... It
> requires typing environments which can be big. Maybe possible but
> sounds odd.
> 
> In toplevel, it should be natural that ppx filters would keep living
> along with the main toplevel process, rather than respawning it for
> each toplevel phrase. But I understand the current design does not
> permit such filter behavior.

If this is the case, then Alain's solution would help. Basically, you
could store only the modules with overloaded values in the cookies,
as parsetree fragments, which would not be very big.

> 
> Jun
> 
> On Mon, Oct 13, 2014 at 10:54 PM, Alain Frisch <alain@frisch.fr> wrote:
>> On 10/13/2014 03:56 PM, Peter Zotov wrote:
>>> 
>>> On 2014-10-13 17:49, Jun Furuse wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I have OPAM-released ppx_overload, a ppx for user definable SML 
>>>> style
>>>> overloading.
>>> 
>>> 
>>> Hi,
>>> 
>>> Great hack! I wanted to do something similar, but yours is much more
>>> elegant than what I had in mind.
>>> 
>>> One note though:
>>> 
>>>> Unfortunately this ppx trick does not work for the toplevel. It is
>>>> since OCaml toplevel
>>>> re-execute the ppx filter each time it gets a toplevel phrase. This
>>>> makes the ppx filter
>>>> hard to keep its state, in this case, the typing environment.
>>> 
>>> 
>>> In 4.02.1 the toplevel allows the ppx rewriter to save some state.
>>> See
>>> 
>>> http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/trunk/parsing/ast_mapper.mli?view=markup#l192.
>> 
>> 
>> 
>> And sedlex ( https://github.com/alainfrisch/sedlex ) illustrates one
>> possible approach for storing the state.  Instead of marshaling in any 
>> form
>> some kind of internal state, it simply stores fragments of parsetree 
>> (here,
>> structure items) that impacted its internal state and simply replay 
>> them on
>> later phrases.  (This is not very efficient, but for quick experiments 
>> in
>> the toplevel, this is fine.)  I don't know if this technique would 
>> apply to
>> ppx_overload.
>> 
>> -- Alain
>> 
>> 
>> 

-- 
Peter Zotov

      reply	other threads:[~2014-10-14 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-13 13:49 Jun Furuse
2014-10-13 13:56 ` Peter Zotov
2014-10-13 14:54   ` Alain Frisch
2014-10-14 13:08     ` Jun Furuse
2014-10-14 14:55       ` Peter Zotov [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=78874d6b72b958db5e74b9b21c18e8d2@whitequark.org \
    --to=whitequark@whitequark.org \
    --cc=alain@frisch.fr \
    --cc=caml-list-request@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jun.furuse@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