* [Caml-list] AST and "when"
@ 2003-01-29 11:20 Mike Potanin
2003-01-29 14:33 ` Olivier Andrieu
0 siblings, 1 reply; 5+ messages in thread
From: Mike Potanin @ 2003-01-29 11:20 UTC (permalink / raw)
To: caml-list
Can CamlP4 make "when" in pattern?
# <:patt< a when a<0 >>;;
^^^^
While expanding quotation "patt":
Parse error: end of input expected after [pattern] (in [pattern])
# <:expr< let p x = match x with a when a<0 -> 1 | b -> b in p z >>;;
^^^^
While expanding quotation "expr":
Parse error: '->' expected after [ipatt] (in [expression])
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] AST and "when"
2003-01-29 11:20 [Caml-list] AST and "when" Mike Potanin
@ 2003-01-29 14:33 ` Olivier Andrieu
2003-01-29 15:33 ` Mike Potanin
0 siblings, 1 reply; 5+ messages in thread
From: Olivier Andrieu @ 2003-01-29 14:33 UTC (permalink / raw)
To: Mike Potanin; +Cc: caml-list
Mike Potanin [Wednesday 29 January 2003] :
> Can CamlP4 make "when" in pattern?
>
> # <:expr< let p x = match x with a when a<0 -> 1 | b -> b in p z >>;;
> ^^^^
> While expanding quotation "expr":
> Parse error: '->' expected after [ipatt] (in [expression])
That should be :
<:expr< let p x = match x with [ a when a<0 -> 1 | b -> b ] in p z >>
AST quotations use the revised syntax.
--
Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] AST and "when"
2003-01-29 14:33 ` Olivier Andrieu
@ 2003-01-29 15:33 ` Mike Potanin
2003-01-29 15:43 ` Olivier Andrieu
0 siblings, 1 reply; 5+ messages in thread
From: Mike Potanin @ 2003-01-29 15:33 UTC (permalink / raw)
To: caml-list
On Wed, 29 Jan 2003, Olivier Andrieu wrote:
> Mike Potanin [Wednesday 29 January 2003] :
> That should be :
> <:expr< let p x = match x with [ a when a<0 -> 1 | b -> b ] in p z >>
>
> AST quotations use the revised syntax.
Thank you!
Can I use <:patt< ... >> for this resalt?
(MLast.PaLid ((0, 0), "a"),
Some
(MLast.ExApp ((0, 0),
MLast.ExApp ((0, 0), MLast.ExLid ((0, 0), "<"),
MLast.ExLid ((0, 0), "a")),
MLast.ExInt ((0, 0), "0")))
<:patt< a when a<0 >>
do not work.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] AST and "when"
2003-01-29 15:33 ` Mike Potanin
@ 2003-01-29 15:43 ` Olivier Andrieu
2003-01-29 16:51 ` Mike Potanin
0 siblings, 1 reply; 5+ messages in thread
From: Olivier Andrieu @ 2003-01-29 15:43 UTC (permalink / raw)
To: Mike Potanin; +Cc: caml-list
Mike Potanin [Wednesday 29 January 2003] :
> On Wed, 29 Jan 2003, Olivier Andrieu wrote:
> > Mike Potanin [Wednesday 29 January 2003] :
> > That should be :
> > <:expr< let p x = match x with [ a when a<0 -> 1 | b -> b ] in p z >>
> >
> > AST quotations use the revised syntax.
>
> Thank you!
> Can I use <:patt< ... >> for this resalt?
I don't think so: in `a when a<0', only the first `a' is a pattern,
the when + expr is part of the `match' (or `try' or `function')
construct which is at the expression level.
> (MLast.PaLid ((0, 0), "a"),
> Some
> (MLast.ExApp ((0, 0),
> MLast.ExApp ((0, 0), MLast.ExLid ((0, 0), "<"),
> MLast.ExLid ((0, 0), "a")),
> MLast.ExInt ((0, 0), "0")))
that's not a single pattern (MLast.patt), that's a tuple of type
`MLast.patt * MLast.expr option'
--
Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] AST and "when"
2003-01-29 15:43 ` Olivier Andrieu
@ 2003-01-29 16:51 ` Mike Potanin
0 siblings, 0 replies; 5+ messages in thread
From: Mike Potanin @ 2003-01-29 16:51 UTC (permalink / raw)
To: caml-list
On Wed, 29 Jan 2003, Olivier Andrieu wrote:
Whether I can make "formula" quotation so it compile
match e with
<:formula< sin(@x) ^ 2 + cos(@x) ^ 2 >> -> <:formula< 1 >>
to
match e with
(Sum [(Pow1 (Sin x) 2); (Pow1 (Cos x_temp) 2)]) when x==x_temp
-> Const 1
Or I mast write
match e with
<:formula< sin(@x) ^ 2 + cos(@y) ^ 2 >> when x==y
-> <:formula< 1 >>
> Mike Potanin [Wednesday 29 January 2003] :
>
> I don't think so: in `a when a<0', only the first `a' is a pattern,
> the when + expr is part of the `match' (or `try' or `function')
> construct which is at the expression level.
>
> > (MLast.PaLid ((0, 0), "a"),
> > Some
> > (MLast.ExApp ((0, 0),
> > MLast.ExApp ((0, 0), MLast.ExLid ((0, 0), "<"),
> > MLast.ExLid ((0, 0), "a")),
> > MLast.ExInt ((0, 0), "0")))
>
> that's not a single pattern (MLast.patt), that's a tuple of type
> `MLast.patt * MLast.expr option'
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-01-29 16:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-29 11:20 [Caml-list] AST and "when" Mike Potanin
2003-01-29 14:33 ` Olivier Andrieu
2003-01-29 15:33 ` Mike Potanin
2003-01-29 15:43 ` Olivier Andrieu
2003-01-29 16:51 ` Mike Potanin
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).