Serabe wrote:
Hi, everyone,

I've been reading compiler2.rb (I still need to read it two or three
times more). I still don't know how to do some details, but here is my
idea.

signature name, array => return

where array is exactly like now but if some parameter is optional,
then it is given in the form [class, initial_value]. Just think that
brackets are constructors, and it could be even nested like
[[MagickImage [BufferedImage, 500, 700]]] => MagickImage would be a
method like def a(magick_image=Geometry.new(500,700)) (returning a
MagickImage object. My first thought wast to create a optional
parameter :optional in the hash with and array of optional parameters.
But this wouldn't be valid in Ruby 1.9.

I'm definitely interested in doing optional arguments. They would manifest in the Java class as a series of signatures of increasing size. So if you defined:

def foo(a = 1, b = 2, c = 2)

There would be four signatures generated from zero to three arguments. Each of the lower-arity versions would simply attach their default value and call the next larger arity version. That's also how I'd planned to do optional arguments in Duby.

Problems:

· Typing too much.
· Not the ruby way (it seems Lisp with brackets).
· Is overload methods hard in jvm?
· How can string objects be introduced in bitescript?

I'm wondering if maybe we could even go a step further and inspect the method arguments. So we would expose a real API for getting metadata about a method's arguments, and then use that for part of the definition. Right now there's absolutely no correlation between the signature you specify and the number or type of arguments on the actual Ruby method. If we could inspect it, then we could get out optional values, required/optional counts, and so on.

- Charlie


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to