Skip to content

Partially-Applied Function with Call-by-Name Params Memoize Values #2351

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

Closed
scabug opened this issue Sep 13, 2009 · 3 comments
Closed

Partially-Applied Function with Call-by-Name Params Memoize Values #2351

scabug opened this issue Sep 13, 2009 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Sep 13, 2009

Consider the following example:

var i = 1
def add(x: =>Int)(y: Int) = x + y
val f = add(i) _

f(1)    // => 2
i += 1
f(1)    // => 2!!!

I would expect the second f(1) to return 3, since the value of i has been incremented. It would seem that the partially-applied form of add (f) is memoizing its call-by-name parameter.

$$ scala -version
Scala code runner version 2.7.4.final -- Copyright 2002-2009, LAMP/EPFL
@scabug
Copy link
Author

scabug commented Sep 13, 2009

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

@scabug
Copy link
Author

scabug commented Sep 15, 2009

@cunei said:
We'll discuss it during our weekly meeting.

@scabug
Copy link
Author

scabug commented Apr 19, 2011

@harrah said:
#302

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