Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec for "update" is insufficiently explicit #4085

Closed
scabug opened this issue Dec 14, 2010 · 4 comments
Closed

spec for "update" is insufficiently explicit #4085

scabug opened this issue Dec 14, 2010 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Dec 14, 2010

Can't believe I'm still finding things out about the language...

An assignment ~\lstinline@$$f$$($$\args\,$$) = $$e$$@~ with a function application to the
left of the `\lstinline@=@' operator is interpreted as 
~\lstinline@$$f.$$update($$\args$$, $$e\,$$)@, i.e.\
the invocation of an \code{update} function defined by $$f$$.

(I don't know how to get a readable excerpt from the spec so I'm pasting the latex.)

So apparently this means (intentionally? I think so, but not sure) that you should "inline args" so that:

// the obvious one for which there are examples
x(a) = b  // x.update(a, b)
// less obvious
x(a, b) = c // x.update(a, b, c)
// less obvious still
x() = a  // x.update(a)

There are no conditions under which one would first expect that f.update(args, e) means that update is variable-arity from 1-N, so I think such a thing should be very explicit and have at least one example of both the "x() = a" sort and "x(a, b) = c" sort. Even if it might technically be derivable from the language which is present.

@scabug
Copy link
Author

scabug commented Dec 14, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4085?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Dec 15, 2010

@milessabin said:
It seems that the following is also accepted,

scala> class Up { def update(as : Int*) {} }                                                                 
defined class Up

scala> val up = new Up                      
up: Up = Up@129dcc0

scala> up() = 0

scala> up(0) = 1

scala> up(0, 1) = 2

scala> up(0, 1, 2) = 3

scala> 

@scabug
Copy link
Author

scabug commented Dec 15, 2010

@milessabin said:
And perhaps even more bizarrely the following is also accepted,

scala> class Up { def update(as : Int*)(d : Double) {} }
defined class Up

scala> val up = new Up                                  
up: Up = Up@1890c67

scala> (up(0) = 1)(1.0)                                 

I'm sure someone can find something useful to do with this.

@scabug
Copy link
Author

scabug commented Jan 30, 2011

@odersky said:
I added some examples to the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants