[Prev][Next][Index][Thread]

Re: Multiply-keyed collection classes



Hugh Greene <q@tardis.ed.ac.uk> wrote:
> On Fri, 14 Apr 2000, Scott McKay wrote:
> > If I were doing it, I would implement the dfa as a subclass of
> > <table> and define a 'table-protocol' that combines both of the keys.
> > The function 'sequence-hash' from the 'table-extensions' library
> > might be a reasonable place to start.
> 
> That sounds reasonable for the state transition table scenario suggested,
> but it doesn't help with making the syntax "pretty".  Neel, I suspect the
> Dylan-style thing here would be option 2 (lookup(dfa, old-state, char)) --
> you may be stuck thinking "pretty = C++/Java" ;-)  The other thing is I'm
> not sure whether or not your dfa really "feels like" a <collection>.

It's actually the transition table for the state machine that I'm
looking to represent as a collection. Since it's a finite function
mapping (<state>, <character>) -> <state>, this seemed like it ought
to have been a perfect fit with the design of the collection
classes. Since it didn't, I thought that perhaps I just didn't
understand things well enough.

Anyway, lookup(machine, state, character) isn't ugly; it's just that
IMO machine[state, character] looks more like pseudocode, and I've
gotten used to that holding true basically all the time in Dylan
code. :)


Neel



Follow-Ups: References: