Original-Via: uk.ac.nsf; Mon, 4 Nov 91 11:35:00 GMT

> Incidentally, I'd suggest that we have separate (c*n) and (n+k) forms of
> pattern ... extending the syntax of patterns to:
> 
>       pat  ::=   .... |   int * pat   |   pat + k
> 
> This would allow c*n+k patterns as a special case, but also permits other
> potentially useful constructions: (2*_+1).  Even a pattern like (n,m)+1
> would make sense if you had an instance of the form Integral (a,b).
> 
> What's more, using the two forms of pattern seems to give a cleaner system
> (I've just added it to Gofer and it seems fairly straightforward).
> 
> Mark
> 

Which semantics did you use?

         case e0 of {p+k -> e; _ -> e'}
either   = if e0 >= k then then let {p = e0-k} in e else e'
or       = let {p = e0-k} in e
or       = if e0 >= k then case e0-k of {p -> e; _ -> e'} else e'
or       = case e0-k of {p -> e; _ -> e'}
(or something else?)

         case e0 of {c*p -> e; _ -> e'}
either   = if e0 >= 0 && e0 `rem` c == 0 then let {p = e0 `div` c} in e else e'
or       = if e0 `rem` c == 0 then let {p = e0 `div` c} in e else e'
or       = if e0 >= 0 then case e0 `divRem` c of (p, 0) -> e; _ -> e'} else e'
or       = case e0 `divRem` c of (p, 0) -> e; _ -> e'}
(or something else?)

Any syntactic restrictions on c or k (e.g. k >= 0, c >= 1)?

   Note, I'm not opposing anything here, I'm just asking!

                        /kent k

Reply via email to