[nem-en] match on specific parameter
d
d at hell.art.pl
Sun Jan 29 10:32:18 CET 2006
On Jan 29, 2006, at 8:17 AM, Michal Moskal wrote:
> However in most cases you only want to match on a single parameter
> (at least I do), so you end up writing:
>
> def rev (acc, lst)
> match (lst)
> | x :: xs => rev (x :: acc, xs)
> | [] => acc
*SNIP*
> I would like something
> like:
>
> def rev (acc, match lst)
> | x :: xs => rev (x :: acc, xs)
> | [] => acc
>
> or maybe "def rev (acc, match)". I'm not sure about the syntax.
Seems we feel similarly in this subject. I like both your syntax
propositions. But there is the issue you mentioned on IRC:
< malekith> unfortunately
< malekith> Rev (acc : list ['a])
< malekith> won't work (inside some variant)
< malekith> that is you cannot say: 'Rev (match this, acc : list ['a])
< malekith> or maybe you should be able...
I think that's reasonable, although not obvious in Nemerle.. For
some people this will be confusing and a bit rightly so, so perhaps
it shouldn't be allowed for [this]. I'll be statisfied whichever
otption you choose ;]
regards,
d
PS. Sorry if this email comes out lousy, it's the first one from a
new client ;]
More information about the devel-en
mailing list