[racket-dev] Instantiation syntax of `new`

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Sun Feb 3 14:28:53 EST 2013

On 2013-02-03 10:50:31 -0500, Tony Garnock-Jones wrote:
> (inst c% 1 2 3)
> (inst c% #:x 1 #:y 2)
> (inst c% 1 2 #:z 3)
> ;; not sure what to do about the last one

Also if you want to play with this, I implemented something like this

I think the syntax was
  (define c%
    (class object%
      (init-field #:x [x 3])))

like function headers. And you can initialize like:

  (new c% #:x 3) or (new c% [x 3])

Although it's a little buggy, because if you change [x 3] to [y 3] it
won't accept #:x and will only accept #:y.


Posted on the dev mailing list.