|Anonymous | Login | Signup for a new account||2014-09-30 19:57 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005904||OCaml||OCaml general||public||2013-01-23 23:15||2014-09-23 16:57|
|Priority||low||Severity||feature||Reproducibility||have not tried|
|Target Version||Fixed in Version|
|Summary||0005904: -ppx could be made working in toplevel|
|Description||I'd like to test my -ppx code in toplevel. Currently -ppx works just offline, using the file system. |
This is a feature wish, and probably requiring some effort, nevertheless I think it's worthwhile.
|Tags||No tags attached.|
edited on: 2013-01-25 10:22
Commit 13278 (trunk) adds support for -ppx to the toplevel. Each phrase (not directives) is passed to external rewriters. Not that when the toplevel is used to execute a script (passed on its command-line, or with #use), then each phrase is rewritten independently. It might be worth sending the whole script to the rewriter instead. It would also allow the rewriter to rewrite directives.
Actually, it would make sense to allow the rewriters to maintain their state across phrases. This could be done by letting the rewriters send (and read back) some extra custom data in addition to the ASTs; this requires the rewriter to maintain a clean notion of state, which can be easily serialized. Otherwise, we could keep the rewriters alive as external processes and talk with them for each phrase. But this requires more complex process control logic (from module Unix).
edited on: 2013-01-27 23:24
That sounds awesome, thanks.
|Is this issue resolved?|
|Support for -ppx has been added to the toplevel, but it can be improved (see my note : "Actually, it would make sense to allow the rewriters to maintain their state across phrases...").|
|A #ppx directive has been added, to add dynamically extra ppx rewriters during a toplevel session.|
Commit 15314 adds a notion of "persistent cookies", which can be set by ppx processors and retrieved on further invocations when called from the toplevel.
Cookies are identified by an arbitrary string and hold an arbitrary Parsetree expression.
It is the responsibility of each ppx processor to store a cookie that represent its state and then restore it (using Ast_mapper.get_cookie/set_cookie). Note that cookies are available when the function registered through Ast_mapper.register is executed, so it is possible to set some global variables there.
|2013-01-23 23:15||meyer||New Issue|
|2013-01-23 23:15||meyer||Status||new => assigned|
|2013-01-23 23:15||meyer||Assigned To||=> frisch|
|2013-01-25 10:15||frisch||Note Added: 0008797|
|2013-01-25 10:16||frisch||Note Edited: 0008797||View Revisions|
|2013-01-25 10:22||frisch||Note Edited: 0008797||View Revisions|
|2013-01-27 23:24||meyer||Note Added: 0008802|
|2013-01-27 23:24||meyer||Note Edited: 0008802||View Revisions|
|2013-07-28 23:36||gasche||Note Added: 0009954|
|2013-07-29 10:36||frisch||Note Added: 0009975|
|2014-05-13 16:46||frisch||Note Added: 0011441|
|2014-09-23 16:57||frisch||Note Added: 0012189|
|Copyright © 2000 - 2011 MantisBT Group|