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

core dump on self-referential closure #4

Open
wryun opened this issue Aug 21, 2012 · 1 comment
Open

core dump on self-referential closure #4

wryun opened this issue Aug 21, 2012 · 1 comment
Labels
Milestone

Comments

@wryun
Copy link
Owner

wryun commented Aug 21, 2012

https://wryun.github.io/es-shell/mail-archive/msg00987.html

This dumps core:

; echo <={@ x{x=@{$*}; $&result $x}}

why? check this one first:

; echo <={@ x{$&result @{$}} X}
%closure(x=X)@ * {$
}

Now, imagine replacing X by the entire closure, and you have a closure
containing a reference to itself. That can never be printed, of
course.

@memreflect
Copy link
Contributor

This issue is caused solely by attempting to print an automatically created closure that somehow refers to itself.
If you avoid trying to display the result, you can pass the resulting lambda around, invoke it with arguments, etc.

The other part of the reason is the fact that some code in conv.c was commented out with #if 0 that handled exactly this case, but the output can be quite noisy as you will see below.

; whatis <={
    @ x a y {
      (a x y) = 0 @{a = $*} {echo $a}
      $&result $x $y
    }
  }
%closure(x='0 $&nestedbinding';a=0;y='%closure(x=''1 $&nestedbinding'';a=0;y=''0 $&nestedbinding'')@ * {echo $x}')@ * {a = $*}
%closure(x='%closure(x=''0 $&nestedbinding'';a=0;y=''1 $&nestedbinding'')@ * {echo $y}';a=0;y='0 $&nestedbinding'){echo $a}

I have suggested abridging of closures in #103, but dropping the #if 0 and corresponding #endif in conv.c will allow you to obtain output like the above, resolving this issue.

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

No branches or pull requests

2 participants