Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:17:19+00:00 2026-05-14T23:17:19+00:00

With named parameters like def f(x : Int = 1, y : Int =

  • 0

With named parameters like

def f(x : Int = 1, y : Int = 2) = x * y

your parameter names become part of the interface

f(x=3)

Now if you want to change the parameter names locally, you are forced to perserve the public name of the parameter:

    def f(x : Int = 1, y : Int = 2) = {
        val (a,b) = (x,y)
        a * b
    }

If this a real problem? Is there a syntax to support this directly? Who do other languages handle this?

A small illustration of the problems you can run into if you switch parameter names, as suggested by Jon.

trait X{ def f(x : Int, y : Int) }
class A extends X{
    override def f(y : Int, x : Int) = println("" + y + x) 
}
val a = new A
scala> a.f(x = 1, y = 2)
21
scala> (a : X).f(x = 1, y = 2)
12
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:17:19+00:00Added an answer on May 14, 2026 at 11:17 pm

    Yes, the parameter name is effectively part of the public interface. This is a “problem” for any language which has named arguments – or indeed produces code which is consumed by languages supporting named arguments. Sometimes this isn’t well understood.

    For example, C# 3 doesn’t support named arguments – but VB does. So if you create a library in C# 3, someone builds against it in VB, then changing parameter names counts as a breaking change.

    Ultimately some of this will be handled by refactoring tools, but it boils down to the same sort of caution as with any other aspect of a public API… you need to be very cautious.

    You should also be very cautious when overriding a method with parameters – use the same parameter names as the original method, or you could cause some very subtle issues. (In particular, switching round the names of parameters would be very evil…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 388k
  • Answers 389k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For my money, it is a poor design becasue it… May 15, 2026 at 12:35 am
  • Editorial Team
    Editorial Team added an answer You can keep the data in a singleton object. Call… May 15, 2026 at 12:35 am
  • Editorial Team
    Editorial Team added an answer str.toCharArray().length should work. Or how about: str.lastIndexOf("") Probably even runs… May 15, 2026 at 12:35 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.