On Mar 9, 2012, at 6:25 AM, Rüdiger Asche wrote:

> (define (vendingmachine currentstate)
>  (let ((newstate
>     (case currentstate
>         [(VENDINGMACHINE_IDLE)
>              (if (CoinInserted)
>                  VENDINGMACHINE_INSERTED_COIN
>                  VENDINGMACHINE_IDLE
>              )
>         ]
>         [(VENDINGMACHINE_INSERTED_COIN)
>              ...
> ...
> 
> where every of the VENDINGMACHINE_xxx identifiers is very simply a readable 
> symbolic identifier for a disjoint constant. I have a hard time believing 
> that in reasonably complex fsms, it shouldn't impose a severe performance 
> penalty to look up a constant every time it is used?

Why not just use symbols for these, without worrying about what they "stand 
for"?  If you've implemented a Scheme system, you know about interned symbols: 
the symbol-table lookup should happen at compile-time (right?), so you're left 
with a constant-time pointer comparison at run-time.

Disclaimer: I've implemented only "toy"-scale Schemes myself.


Stephen Bloch
sbl...@adelphi.edu


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to