Re: Structures
- From: tim <TimJ@xxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 21:01:35 -0000
On Sat, 29 Mar 2008 13:06:23 -0700, Tayssir John Gabbour wrote:
On Mar 29, 8:31 pm, dstein64 <DStei...@xxxxxxxxx> wrote:
Is it still common to use structures in common lisp code? Is there
any reason I should avoid them? It seems that some of the newer
guides do not mention them. Thanks!
I started off using lists for my compiler but eventually I got sick of
remembering that (nth 11 data-item) was level-nbr, etc. Especially I got
sick of forgetting these pieces of information. So I switched to structs to
hold the various parse tree elements. This has worked quite well.
* Gives fields meaningful names.
* Provides some error checking at run time.
Lisp allows structures to incorporate other structures: "(:include
included-structure-name {slot-description}*)". This is good because all my
grammar structures can share a common header.
On the down side it makes the code more verbose at times. One problem with
completely dynamic typing is that the compiler does not know the types of
data and so you always have to tell it at some cost in tokens you have to
type in. Also defstruct by default names the accessors
[struct-name]-[field-name] which makes for long names.
Another downside is that generic routines that walk trees and lists no
longer work because they don't understand structures. I wrote a structure
walking function that supports a visitor type pattern to get around this.
Tim
.
- Follow-Ups:
- Re: Structures
- From: Ken Tilton
- Re: Structures
- References:
- Structures
- From: dstein64
- Re: Structures
- From: Tayssir John Gabbour
- Structures
- Prev by Date: Re: tasters wanted
- Next by Date: Re: tasters wanted
- Previous by thread: Re: Structures
- Next by thread: Re: Structures
- Index(es):
Relevant Pages
|
|