Re: [racket] One accessor for the same fields of different structs?

2013-11-25 Thread Matthias Felleisen
> Sent from my tablet device > > > > -Original Message- > From: Ben Duan > To: users > Sent: Mon, 25 Nov 2013 9:25 AM > Subject: [racket] One accessor for the same fields of different structs? > > Hi All, > > If I have several structures, lik

Re: [racket] One accessor for the same fields of different structs?

2013-11-25 Thread William J. Bowman
ocs.racket-lang.org/reference/mzlib_class.html -- William J. Bowman Sent from my tablet device -Original Message- From: Ben Duan To: users Sent: Mon, 25 Nov 2013 9:25 AM Subject: [racket] One accessor for the same fields of different structs? Hi All, If I have several structures

Re: [racket] One accessor for the same fields of different structs?

2013-11-25 Thread Laurent
No need for a macro here, you simply need to define a common parent struct `person', and derive `customer' and `student' from this struct: (struct person (name age)) (struct customer person (foo)) (struct student person (bar)) (person-name (customer "Joe" 34 'foo)) ; -> "Joe" The parent struct n

[racket] One accessor for the same fields of different structs?

2013-11-25 Thread Ben Duan
Hi All, If I have several structures, like the following: (struct customer (name age foo)) (struct student (name age bar)) I choose the same representation for the `name` and `age` fields which are `string?` and `natural-number/c`. So I think I could just define a `name` accessor for bot