nicholasbs/statemachines — comment on commit 4fc7e8d6e8b7414c8f30a2ad7f2a4be01f049fec
File: pda.ss line 15
By nicholasbs:

Awesome, thanks! You read my mind; I told Dave last night that I
wanted to ask you how to improve this code :)

I'll look for something like define-record/structure.

On Wed, Oct 19, 2011 at 5:27 AM, Andrew Gwozdziewycz

wrote:
> I'm not sure if neil/sicp has this, but most scheme implementations have a `define-record` or `define-structure` macro that takes care of this for you. It also creates accessors (and setters) that, by convention, don't begin with "get-" (which is very much a javaism).
>
> SRFI-9 has `define-record-type` which looks like this. It's verbose, but that's because R5RS macros don't allow you introduce your own names in them so they have to be provided. In R6RS, this could be simplified drastically, because syntax-case macros allow you to break hygiene and introduce names. This maybe more explanation than you were looking for, but whatever!
>
> (define-record-type pda
> (make-pda start-state accept-state transitions)
> pda?
> (pda-start-state start-state)
> (pda-accept-state accept-state)
> (pda-transitions transitions))
>
> (Not that this matters, but `define-record-type` will end up using a vector and field access is therefore constant time.)
>
> --
> Reply to this email directly or view it on GitHub:
> https://github.com/nicholasbs/statemachines/commit/4fc7e8d6e8b7414c8f30a2ad7f2a4be01f049fec#commitcomment-660636
>