2866Re: Is it possible to get an instantiatable pattern matching?
- Jan 1, 2005Hi
Yamagata Yoriyuki <yoriyuki@...> writes:
> Hi,Yes, I agree that there are some type related problems in that.
> From: Code 17 <code17@...>
> Subject: "ocaml_beginners":: Is it possible to get an instantiatable pattern matching?
> Date: Fri, 31 Dec 2004 14:09:44 +0100
> Your mechanism in its general form breaks the type checking. There is
> no way for the compiler to know what type will be accepted to a
> runtime-generated pattern.
At least, there obviously should be some special pattern type that
could handle every possible typed patterns being provided before this
mechanics could hold. This could (or not) be done by the ocaml
compiler. It's just interesting to know whether it is possible to make
pattern as first class value now or in the future. :)
>Thanks for suggestion.
> However, for the simple case, you can use "when" clauses for the
> similar effects.
> let today = 31
> match date with
> (today', this_month', this_year') when today' = today ... ->
> <do something>
This does give some freedom to the user, however, the actual tuning way
here is "equal" not "matching". :)
> Yamagata Yoriyuki
- << Previous post in topic Next post in topic >>