[racket-dev] Instantiation syntax of `new`

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri Feb 1 15:29:57 EST 2013

Hi all,

I've found that when using racket/class, one syntactic pain point I keep
encountering is that the instantiation is clumsy. This is especially
true if I want to mix different styles of instantiation (keyword and
positional).

Is there any reason to not make the instantiation syntax of `new` more
flexible? I most prefer `new` since it's the shortest and also most
familiar of the three (the others being `make-object` and
`instantiate`).

In particular, I'm imagining the following syntax:

  (new c% 1 2 3)       => (instantiate c% (1 2 3))
  (new c% [x 1] [y 2]) => (instantiate c% [x 1] [y 2])
  (new c% [z 3] 1 2)   => (instantiate c% (1 2) [z 3])
  (new c% 1 [z 3] 2)   => (instantiate c% (1 2) [z 3])

and so on. Attached is a patch that implements this (modulo tests &
docs). Any thoughts?

Cheers,
Asumu

Posted on the dev mailing list.