SOMns icon indicating copy to clipboard operation
SOMns copied to clipboard

Object Literals break Value semantics

Open smarr opened this issue 6 years ago • 0 comments

The current implementation of object literals is unfortunately not yet taking into account value semantics properly:

class Foo new: v = Value (
| public v = v. |
)()

public main: args = (
  | d |
  d:: objL Value ()( public getD = ( ^ d )).
  Foo new: d.
  'Hello World!' println.
)

The above example shows that the local variable d can be captured, it is mutable, and Foo new: doesn't signal a NotAValue error, which it should.

@richard-roberts, this is something that should be fixed "at some point". Nothing urgent. Naming you here mostly since this is introduced by #112.

smarr avatar Aug 07 '17 09:08 smarr