Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@nhplace.com>
Date: 09 May 2007 10:45:10 -0400
Local: Wed, May 9 2007 10:45 am
Subject: Re: Does ANSI Common Lisp have pattern matching?
Jon Harrop <j...@ffconsultancy.com> writes: No, I wouldn't say that. But you must at least understand whether you > Kent M Pitman wrote: > > Be careful here. In static languages, pattern matching encourages and > > exploits abstraction, while in Lisp and other dynamic languages, it can > > bypass intentional type and dispatch on representational type, which is > > not always what is wanted. > Can you elaborate on this? Do you mean that pattern matching encourages you are dispatching on declared type or representational type. Lisp, which does not use so-called "strong typing", doesn't know the declared type of the data it receives; it knows the dynamically accessible representational type. That's different and sometime may have different effects. If you're just dealing with data structures as pure shapes, it's fine. Assume these are three independent abstractions: (defun make-simple-frob () 'frob) (defun make-foo (x) (list 'foo x)) (defun make-frob (x) (list 'frob (list 'foo x))) Now assume I do: (pattern-case v in some language where (frob $x) is the pattern with frob being a Then if I give v as the result of (list (make-simple-frob) (make-foo 3)), It's hard to make a direct comparison to strongly typed languages, since Note well: You might assume punning is just bad and has no place in Language choices are not about Good vs Bad, they are about design For other related issues, see my http://www.nhplace.com/kent/PS/EQUAL.html You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||