Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!deccrl!bloom-beacon!eru!hagbard!sunic!mcsun!corton!ilog!barbes!davis From: davis@barbes.ilog.fr (Harley Davis) Newsgroups: comp.lang.scheme Subject: Re: Destructuring / pattern-matching (was: Multiple return values) Message-ID: Date: 12 Apr 91 07:16:28 GMT References: <12542.9104111347@subnode.aiai.ed.ac.uk> Sender: davis@ilog.fr Organization: ILOG S.A., Gentilly, France Lines: 40 In-reply-to: jeff@aiai.edinburgh.ac.UK's message of 11 Apr 91 13:47:48 GMT In article <12542.9104111347@subnode.aiai.ed.ac.uk> jeff@aiai.edinburgh.ac.UK (Jeff Dalton) writes: > From: Jon L White > This was particularly useful in the VAX/NIL compiler and assembler > where much more use was made of simple vectors rather than lists. > We even had a version that would destructure over DEFSTRUCT instances, > in the expectation that "objects" like vectors and structures would > displace lists as the more common data structure "of choice". The obvious answer in Lisp seems to be: write a macro to do whatever pattern-matching or destructuring you want. Unfortunately, it seems to be sufficiently hard to design a good macro that programmers often write out what they want by hand instead, even when they can make use of DESTRUCTURING-BIND. JonL writes: > I'm always having to intersperse lines of LET's amongst multiple > incarnations of DESTRUCTURING-BIND, as well as with MULTIPLE-VALUE-BIND's. Nonetheless, I think the best way to proceed would be for people to write macros that they find useful, let others use them, and see what solutions evolve. I think a simple macro solution is largely sufficient. For example, we have a simple DESTRUCTURING-LET macro in our Lisp. In approximately 60,000 lines of Lisp kernel code, there are exactly four uses of this macro. We avoid extensive use of such a feature because there are very few list structures being passed around which need to be destructured. If we need to look at certain object components within a function, it is best to use accessors to avoid dependency on implementations of objects using particular slot names; in this case, LET is sufficient. -- Harley Davis -- ------------------------------------------------------------------------------ nom: Harley Davis ILOG S.A. net: davis@ilog.fr 2 Avenue Gallie'ni, BP 85 tel: (33 1) 46 63 66 66 94253 Gentilly Cedex, France