[racket-dev] Instantiation syntax of `new`

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Sun Feb 3 11:00:51 EST 2013

On 2013-02-03 10:50:31 -0500, Tony Garnock-Jones wrote:
> How about
>
> (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

I considered something like this, where the keyword's symbolic name is
just used for the corresponding init arg (so it's backwards compatible)
and you could write

  (class object%
    (super-new)
    (init-field #:x 5))

for example.

It seems like it could just be more of a mess, though, since it then
offers a fourth way to instantiate classes. It would be nicely
compatible with function syntax though.

Matthias also suggested in passing a `new` that uses a special marker:

  (new c% [z 3] % 1 2)
  (new c% % 1 2 3)

to make it unambiguous. I'm not sure if this has enough advantages over
`instantiate` (aside from the name) though.

Cheers,
Asumu

Posted on the dev mailing list.