[plt-scheme] The role of proper and improper lists?
On Fri, 25 Jan 2008 08:32:29 -0600
"Robby Findler" <robby at cs.uchicago.edu> wrote:
> On Jan 25, 2008 8:30 AM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> >
> > On Jan 25, 2008, at 9:16 AM, Stephen De Gabrielle wrote:
> >
> > > Good point,
> > > and where structs are insufficient use objects.
> > >
> > > what I struggle with is *when* to change from list to struct to
> > > object?
> >
> >
> > I go from structs to objects when I have several functions of the shape
> >
> > ;; f : StructOfFoo .. Other Types ... -> ...
> >
> > and I wish to present this code to students past their first year or
> > maintain it for a while.
You don't wait until you need polymorphic dispatch on variants
of StructOfFoo? I would have thought that plain structs were
fine up until that point. Well, that's how I've been coding
so-far, but I'm still just an egg at this scheme thing.
(and consequently I haven't actually used any objects, yet...)
> > I stick with structs when first-year students may look at my code.
> >
> > I never replace lists with structs or objects. -- Matthias
>
> But you probably also never use lists of a fixed length to represent
> things that probably should have been structs, either.
But there's so much less convenient lispy mechanism around to
deal with structs. I find myself addicted to apply, match, and
match-let for destructuring struct-like lists, and can't find an
equivalent mechanism for structs. Is there one? Not to mention
the convenience of throwing an alist into a hash table when
random access is important.
Cheers,
--
Andrew