[racket] Redefining selectors - another newbie question
This is fairly easy, but do you really want to avoid typing '-'? I
think what you want is this:
Given:
(struct point (x y))
(define pt (point 1 2))
Currently, you write:
(point-x pt)
You want to write:
(pt.x)
Amirite?
N.
On Thu, Jul 1, 2010 at 3:35 PM, Brad Long <brad at longbrothers.net> wrote:
> Thankyou racket gurus for your advice. My program using a "loop" now works:
> (for-each (fn(x)(display x)(newline)) (.. 10 1)) (display "blastoff!")
> --
> I have another question, is it possible (preferably easy) to use dot
> notation for the auto-generated selectors (e.g. for (point x y z), instead
> of point-x can we use point.x)? I am not exactly sure how to redefine that
> since it is auto-created on construction of the struct.
>
> I have just donned my flame-proof clothing.
>
> Thanks.