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

Recursive update exception: assignment to a cage with lazy right hand side is a problem! #462

Closed
dours opened this issue Nov 29, 2021 · 15 comments

Comments

@dours
Copy link
Contributor

dours commented Nov 29, 2021

[] > infinite-loop
  cage > x
  seq > @
    x.write 0
    x.write (x.add 1)
    x.eq 1

fails.

Of course: x.write (x.add 1) is implemented basically as x := (lambda nothing -> x + 1). Any attempt to calculate x leads to endless recursion.

@dours
Copy link
Contributor Author

dours commented Nov 29, 2021

The previous eaxmple only uses dataizable objects, so it does not need cage. But here is an example, which is not implementable with memory:

[] > infinite-loop-2
  [first second] > pair
  [head list] > addHead
    pair head list > @
  cage > lst
  seq > @
    lst.write (pair 1 0)
    lst.write (addHead 2 lst)
    lst.second.second.eq 0

@dours dours changed the title Recursive update exception: assignment with lazy right hand side is a problem! Recursive update exception: assignment to a cage with lazy right hand side is a problem! Nov 29, 2021
@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours it seems that we should get back to the "dataized" idea, which was abandoned some time ago: #354 Your code would be:

[] > infinite-loop
  cage > x
  seq > @
    x.write 0
    x.write (dataized (x.add 1))
    x.eq 1

Will this work?

@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours on second thought, it seems that this won't help, since dataized would be yet another object in the recursion chain...

@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours another option is this:

[] > infinite-loop
  cage > x
  seq > @
    x.write 0
    x.add 1 > a!
    x.write a
    x.eq 1

@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours or this one:

[] > infinite-loop
  cage > x
  seq > @
    x.write 0
    x.write (x.add 1).@
    x.eq 1

@dours
Copy link
Contributor Author

dours commented Dec 1, 2021

@yegor256 what does .@ mean? Does it also call dataization?

What about the second example, infinite-loop-2?

[] > infinite-loop-2
  [first second] > pair
  [head list] > addHead
    pair head list > @
  cage > lst
  seq > @
    lst.write (pair 1 0)
    lst.write (addHead 2 lst).@
    lst.second.second.eq 0

does not work (StillAbstract exception)

@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours yes, .@ is basically a dataization. For example, random.@ > x means: "x is the object which is decorated by random". In order to find out who it is, we have to ask random this question. And the answer will be, for example, 0.4738383. We will not ask random again. We will assign x to the float number.

@yegor256
Copy link
Member

yegor256 commented Dec 1, 2021

@dours try this:

lst.write ((addHead 2 lst).@)

Maybe it's a syntax problem. But I doubt it. Please, post your entire stack trace.

@dours
Copy link
Contributor Author

dours commented Dec 1, 2021

@yegor256 I don't think that it is a syntax problem. I just don't want to dataize the right hand side of assignment in this example, because it is not dataizable. I try to express a list as a pair of head (the first element of a list) and tail (the rest of the list, which is a list itself).

I construct a list with two elements by adding a head to a list with one element (lst.write (addHead 2 lst)).

But if I'm forced to dataize the right hand side of that assignment, then the representation of my list is changed in the middle of construction, that's the problem! (I mean, even if I make my list implementation dataizable, a dataization of a list is not the list itself, how can I add an element to it?).

Is this stack trace entire enough? I don't know how to get rid of "... 88 more". Maybe, you don't need the trace to answer my question.

�[1;34mINFO�[m] Running EOorg.EOeolang.EOgray.�[1mEOinfinite_loop_2Test�[m
·𝔻( seq.steps ≡ array(Δ ↦ ⟦ι0 ↦ infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.pair(#0 ↦ int(Δ ↦ 1))(#1 ↦ int(Δ ↦ 0))), ι1 ↦ infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.addHead(#0 ↦ int(Δ ↦ 2))(#1 ↦ infinite-loop-2.lst).φ), ι2 ↦ infinite-loop-2.lst.second.second.eq(#0 ↦ int(Δ ↦ 0))⟧) ) ➜ ⟦ι0 ↦ infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.pair(#0 ↦ int(Δ ↦ 1))(#1 ↦ int(Δ ↦ 0))), ι1 ↦ infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.addHead(#0 ↦ int(Δ ↦ 2))(#1 ↦ infinite-loop-2.lst).φ), ι2 ↦ infinite-loop-2.lst.second.second.eq(#0 ↦ int(Δ ↦ 0))⟧
·𝔻( infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.pair(#0 ↦ int(Δ ↦ 1))(#1 ↦ int(Δ ↦ 0))) ) ➜ true
·𝔻( infinite-loop-2.lst.write(#0 ↦ infinite-loop-2.addHead(#0 ↦ int(Δ ↦ 2))(#1 ↦ infinite-loop-2.lst).φ) ) ➜ true
[�[1;31mERROR�[m] �[1;31mTests �[0;1mrun: �[0;1m1�[m, Failures: 0, �[1;31mErrors: �[0;1;31m1�[m, Skipped: 0, Time elapsed: 0.012 s�[1;31m <<< FAILURE!�[m - in EOorg.EOeolang.EOgray.�[1mEOinfinite_loop_2Test�[m
[�[1;31mERROR�[m] EOorg.EOeolang.EOgray.EOinfinite_loop_2Test.testWorks  Time elapsed: 0.004 s  <<< ERROR!
org.eolang.Attr$StillAbstractException: Error at "EOorg.EOeolang.EOgray.EOinfinite_loop_2Test.EOinfinite_loop_2Test$EOpair#eq" attribute
	at org.eolang.AtNamed.get(AtNamed.java:79)
	at org.eolang.PhDefault.attr(PhDefault.java:209)
	at org.eolang.PhNamed.attr(PhNamed.java:82)
	at org.eolang.PhNamed.attr(PhNamed.java:82)
	at org.eolang.PhNamed.attr(PhNamed.java:82)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhMethod.lambda$new$0(PhMethod.java:42)
	at org.eolang.Data$Once.take(Data.java:90)
	at org.eolang.PhOnce.copy(PhOnce.java:71)
	at org.eolang.Data$Once.take(Data.java:90)
	at org.eolang.PhOnce.attr(PhOnce.java:81)
	at org.eolang.PhWith.lambda$new$3(PhWith.java:72)
	at org.eolang.Data$Once.take(Data.java:90)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhDefault.attr(PhDefault.java:209)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhOnce.attr(PhOnce.java:86)
	at org.eolang.PhDefault.attr(PhDefault.java:209)
	at org.eolang.Dataized.take(Dataized.java:71)
	at org.eolang.Dataized.take(Dataized.java:107)
	at EOorg.EOeolang.EOgray.EOinfinite_loop_2Test.testWorks(EOinfinite_loop_2Test.java:76)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1508)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1508)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: org.eolang.Attr$StillAbstractException: Can't get(), attribute "eq" is absent among other 4 attrs (ρ, σ, first, second) and φ is absent
	at org.eolang.AtAbsent.get(AtAbsent.java:70)
	at org.eolang.AtNamed.get(AtNamed.java:75)
	... 88 more

@yegor256
Copy link
Member

yegor256 commented Dec 2, 2021

@dours you understand the error message? It says that it can't find eq in the object. Thus, lst.second.second is pair. Does this information help?

yegor256 added a commit that referenced this issue Dec 7, 2021
yegor256 added a commit that referenced this issue Dec 7, 2021
yegor256 added a commit that referenced this issue Dec 9, 2021
@yegor256
Copy link
Member

yegor256 commented Dec 9, 2021

@rultor release, tag is 0.20.0

@rultor
Copy link
Contributor

rultor commented Dec 9, 2021

@rultor release, tag is 0.20.0

@yegor256 OK, I will release it now. Please check the progress here

@rultor
Copy link
Contributor

rultor commented Dec 9, 2021

@rultor release, tag is 0.20.0

@yegor256 Done! FYI, the full log is here (took me 25min)

@yegor256
Copy link
Member

yegor256 commented Dec 9, 2021

@dours I believe this problem is fixed in version 0.20.0. Try this code:

[] > avoid-infinite-loop
  cage > x
  x' > copy
  seq > @
    x.write 42
    copy.<
    x.write (7.add copy)
    x.eq 49

The new syntax introduced is x' -- it explicitly makes a copy of an object. Also, in order to make sure the copy is ready before the write is happening, we do this:

copy.<

This line, when being dataized by seq, makes sure the copy is alive. More tests here: https://github.com/cqfn/eo/blob/master/eo-runtime/src/test/eo/org/eolang/gray/cage-tests.eo

@yegor256 yegor256 closed this as completed Dec 9, 2021
yegor256 added a commit that referenced this issue Dec 9, 2021
yegor256 added a commit that referenced this issue Dec 9, 2021
yegor256 added a commit that referenced this issue Dec 9, 2021
yegor256 added a commit that referenced this issue Dec 9, 2021
@0crat
Copy link

0crat commented Dec 9, 2021

Job gh:cqfn/eo#462 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

4 participants