[wg-camlp4] My uses of syntax extension
Alain Frisch
alain at frisch.fr
Mon Jan 28 17:55:02 GMT 2013
On 01/28/2013 06:13 PM, David Waern wrote:
> OK. I've also wanted similar syntax, but I've noticed that if Alain's
> "static exceptions" [1] proposal is accepted then encoding such things
> using existing OCaml syntax becomes a bit lighter:
>
> try raise (`Cont expr) with
> | `Cont n -> expr
> | handlers
As a side note, this encoding with static exceptions is also much more
efficient (no allocation required to escape from the exception handler).
Still, this is a good example. One might indeed want to use a dedicated
syntax for this common idiom. My preference would be for extending the
official language to support it directly. If one thinks it is generally
useful, why not put it in the language itself? It is not difficult to
extend OCaml to support it directly.
If the proposal is rejected but we have let-fix operators, one can
decide to have a -ppx rewriter detecting and rewriting the following form:
let? x = try e1 with p -> e2 in
e3
-- Alain
More information about the wg-camlp4
mailing list