On 02/01/2013 03:29 PM, Asumu Takikawa wrote:
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])

I think you mean (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?

It's ambiguous:

  (new c% (x y))

could mean "pass y for initialization argument x" or "pass (x y) as the first positional argument".

Ryan

_________________________
 Racket Developers list:
 http://lists.racket-lang.org/dev

Reply via email to