🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #221

Pattern matching considered harmful

#221
From: Jeff Dalton
Date: Fri, 25 May 1990 19:53
21 lines
1421 bytes
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.
Technical Details
Message-ID: <2584@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!edcastle!aiai!jeff

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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