Loading ...
Sorry, an error occurred while loading the content.

2866Re: Is it possible to get an instantiatable pattern matching?

Expand Messages
  • code17
    Jan 1, 2005
    • 0 Attachment
      Hi

      Yamagata Yoriyuki <yoriyuki@...> writes:

      > Hi,
      >
      > 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.

      Yes, I agree that there are some type related problems in that.
      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. :)

      >
      > 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>
      > ...

      Thanks for suggestion.
      This does give some freedom to the user, however, the actual tuning way
      here is "equal" not "matching". :)

      Thanks.

      >
      > --
      > Yamagata Yoriyuki
    • Show all 10 messages in this topic