Xref: utzoo comp.lang.functional:119 comp.lang.prolog:2715 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!edcastle!aiai!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.functional,comp.lang.prolog Subject: Pattern matching considered harmful Message-ID: <2584@skye.ed.ac.uk> Date: 25 May 90 19:53:39 GMT Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 21 Pattern-matching is fine for lists, when it's really lists that should be used. More generally, pattern matching would be ok if, for a given structure type (or Prolog term or whatever), it were used only in a small set of basic operations. However, programmers all too often use pattern matching throughout their programs and then, when they change the number or order of fields in a structure, have to go around and change all the patterns. Moreover, to read a pattern one often has to count commas, which is error-prone to say the least. This sort of thing happens all the time in Prolog and probably in functional languages as well. Some Prolog programmers have told me that, of course, one could use a notation that involved named fields and then expand (unfold) this into patterns. Few programmers actually do this, however. Given these problems, I wonder why pattern-matching seems to be regarded, rather uncritically, as a Good Thing. Abstraction is a wonderful thing, when it's used.