Named and default arguments SID

View: New views
3 Messages — Rating Filter:   Alert me  

Named and default arguments SID

by Stepan Koltsov-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, all.

I've just read latest version of named and default arguments specification

http://www.scala-lang.org/sid/1

In first version of specification, unset arguments were passed by
extra mask parameter.

In this verison, for each argument with default value extra method is created.

First version has an advantage of much simpler bytecode (only one
extra method in declaration, and no extra method calls at method call
site), so smaller class size, faster code loading, reduced memory
usage and so on.

What are advantages of current specification?

S.

Re: Named and default arguments SID

by Lukas Rytz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Sat, Jun 6, 2009 at 14:56, Stepan Koltsov <stepancheg@...> wrote:
Hi, all.

I've just read latest version of named and default arguments specification

http://www.scala-lang.org/sid/1

In first version of specification, unset arguments were passed by
extra mask parameter.

In this verison, for each argument with default value extra method is created.

First version has an advantage of much simpler bytecode (only one
extra method in declaration, and no extra method calls at method call
site), so smaller class size, faster code loading, reduced memory
usage and so on.

What are advantages of current specification?


IIRC, the first version didn't work well for
 - call site evaluation order
 - subclassing (inheriting / adding / overridding defaults)

Lukas

Re: Named and default arguments SID

by Stepan Koltsov-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Jun 6, 2009 at 17:30, Lukas Rytz<lukas.rytz@...> wrote:

>> Hi, all.
>>
>> I've just read latest version of named and default arguments specification
>>
>> http://www.scala-lang.org/sid/1
>>
>> In first version of specification, unset arguments were passed by
>> extra mask parameter.
>>
>> In this verison, for each argument with default value extra method is
>> created.
>>
>> First version has an advantage of much simpler bytecode (only one
>> extra method in declaration, and no extra method calls at method call
>> site), so smaller class size, faster code loading, reduced memory
>> usage and so on.
>>
>> What are advantages of current specification?
>
> IIRC, the first version didn't work well for
>  - call site evaluation order

Explain, please.

>  - subclassing (inheriting / adding / overridding defaults)

Defaults should not be overridable, whatever specification is. I. e.
when you override method, you cannot specify any default parameters.
That makes specification and implementation simpler.

S.