Xref: utzoo comp.lang.functional:150 comp.lang.prolog:2757 Path: utzoo!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!usc!cs.utexas.edu!uunet!mcsun!ukc!edcastle!aiai!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.functional,comp.lang.prolog Subject: Re: Pattern matching considered harmful Message-ID: <2631@skye.ed.ac.uk> Date: 3 Jun 90 16:27:25 GMT References: <2584@skye.ed.ac.uk> <3077@goanna.cs.rmit.oz.au> <2790@syma.sussex.ac.uk> Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 38 In article <2790@syma.sussex.ac.uk> aarons@syma.sussex.ac.uk (Aaron Sloman) writes: >I don't see any difference between this problem and the problem >arising in any programming language where you define procedures or >functions with arguments of certain types and then have to invoke >them by giving the right number of arguments in the right order. Do you really see no advantage to using functions to extract parts of structures rather than some positional notation? A possibly related question is: do you find nothing wrong with functions/procedures that take, say, 7 positional arguments? >E.g. to check whether something (x) is a list one of whose elements >is a list containing "a" preceded by "b" with an arbitrary number of >elements in between, in Pop-11 you'd write > > if x matches [ == [ == a == b == ] == ] then .... > >where "==" matches an arbitrary number of items. In most languages >you'd have to write at least three nested loops to do this and would >probably not get it right first time. In Common Lisp: (some #'(lambda (sublist) (member 'b (member 'a sublist))) x) Not that this proves anything. Besides, what you'd really do in Lisp would be to write some procedures or macros that made it easier to express such things. By the way, what happens with a pattern like [[??a ??b] ??a] "[??a ??b]" can match in more than one way. Will more than one possibility be tried when trying to match the second "??a"? -- Jeff