« Return to Thread: Re: [scala-user] Problem with default arguments and multiple method signatures

Re: Re: [scala-user] Problem with default arguments and multiple method signatures

by David MacIver :: Rate this Message:

Reply to Author | View in Thread

2009/6/2 Lukas Rytz <lukas.rytz@...>:

>
>
> On Tue, Jun 2, 2009 at 14:43, James Iry <jamesiry@...> wrote:
>>
>> Would it be feasible to mangle the getter's name using the parameter types
>> of the overloaded methods?
>>
>> def foo(x : T1 = xdef, y : T2 = ydef)
>> def foo(z : T3 = zdef, zz : T4 = zzdef)
>>
>> def foo$T1$T2$defaul1 = xdef
>> def foo$T1$T2$defaul2 = ydef
>> def foo$T3$T4$default1 = zdef
>> def foo$T3$T4$default2 = zzdef
>
> That would probably work, except that for some types it's not obvious
> how to convert them into a name:
>
>    def foo(x: { def bar(): Int } = new { def bar() = 1 })
>    def foo(x: String = "uh")
>
>
> What do people think, is it too much limitation if we restrict defaults
> to one overloaded alternative? After all, defaults often allow you to get
> rid of overloads.

Personally I don't have a problem with the restriction, and I find it
very convenient that the generated method names are so
straightforward. That being said, if there's a massive popular opinion
that the restriction is too onerous and it doesn't introduce weird
ambiguities to lift it, I don't care that much. :-)

 « Return to Thread: Re: [scala-user] Problem with default arguments and multiple method signatures