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

Problem when using cage with nested memory #481

Closed
IamMaxim opened this issue Dec 10, 2021 · 3 comments
Closed

Problem when using cage with nested memory #481

IamMaxim opened this issue Dec 10, 2021 · 3 comments

Comments

@IamMaxim
Copy link

I'm trying to implement basic class with mutable variable in EO. The code is:

+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+alias org.eolang.gray.cage

[] > classObject
  [] > new
    [] > @

[] > classA
  classObject > @
  [] > new
    classObject.new > super
    [] > this
      super > @
      memory > i
      [this i] > run_constructor
        seq > @
          this.i.write i
          this
      [this x] > f
        seq > @
          this.i.write x
          this
      [this y] > g
        seq > @
          this.f this (y.add 1)
          this
    seq > @
      this.i.write 0
      this
  [i] > constructor
    new > this
    seq > @
      this.run_constructor this i
      this

[args...] > app
  cage > a
  seq > @
    a.write
      classA.constructor 42
    stdout
      sprintf "%d\n" (a.i)
    a.f a 43
    stdout
      sprintf "%d\n" (a.i)
    a.g a 44
    stdout
      sprintf "%d\n" (a.i)

While this.i.write works fine in run_constructor, it fails in a.f with output:

42
Exception in thread "main" org.eolang.Attr$StillAbstractException: The attribute is not initialized, can't read
...

I played with this code for several hours, but couldn't find a way to bypass it.

@yegor256
Copy link
Member

@IamMaxim it seems that the problem is related to this: #462 I believe, you should do a' instead of a when you call a.f with itself. Read #462, it should help.

@yegor256
Copy link
Member


`i` shadows the attribute of the object being decorated.

@0crat
Copy link

0crat commented Dec 17, 2021

Job gh:cqfn/eo#481 is not assigned, can't get performer

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

No branches or pull requests

3 participants