[cduce-users] default match policy not working in sequences

Matthias Radestock matthias at sorted.org
Tue Nov 2 19:26:04 CET 2004


Giuseppe Castagna wrote:

> What you probably wanted to write is
> 
> # let [(x & 1)] | (x := 2) = [3];;
> val x : 2 = 2
> 

Unfortunately this technique doesn't work nearly so well when the 
sequence contains multiple elements. The specific example where I ran 
into this problem is

[<current-state>state
  <next-state>TicketState?
  <next-days>String?
  ((<next-date>[(date::Char* 'UTC' Char*)]) | (date := "Unknown"))
  <subscription-code>subscriptionCode
  <machine-name>machineName]

which I had expected to match sequences with or without a valid 
next-date element, returning a date value of "Unknown" in the latter case.

The only way I could get this to work involves repeating the entire 
sequence pattern:

[<current-state>state
  <next-state>TicketState?
  <next-days>String?
  <next-date>[(date::Char* 'UTC' Char*)]
  <subscription-code>subscriptionCode
  <machine-name>machineName] |
[<current-state>state
  <next-state>TicketState?
  <next-days>String?
  <next-date>String?
  <subscription-code>subscriptionCode
  <machine-name>machineName] & (date := "Unknown")

Is there a better way to do this?


Matthias.




More information about the Cduce-users mailing list