These are chat archives for evhub/coconut

23rd
Jul 2018
yggdr
@yggdr
Jul 23 2018 06:56
@evhub What I find strange is the change in Error message depending on whether a top-level function of the same name happens to be defined or not. This might indicate a subtle bug.
>>> class A:
     def meth(self, arg):
      return meth(self, arg)

>>> A().meth(2)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 33, in tail_call_optimized_func
  File "<string>", line 5, in meth
NameError: name 'meth' is not defined
>>> def meth(self, arg):
     return arg

>>> A().meth(2)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 33, in tail_call_optimized_func
  File "<string>", line 5, in meth
NameError: name '_coconut_recursive_func_0' is not defined
>>>
'jamin
@acdimalev
Jul 23 2018 08:52
In the first case, the error message is straight forward; there isn't a function called meth. I'm wondering if the second case is REPL-specific... is the error message the same if the function is defined first? It's strange seeing a TCO error on a non-recursive function.
David O'Gwynn
@dogwynn
Jul 23 2018 13:55
  • Not REPL-specific.
  • Order does not matter
  • Seems to be that the naming of the function/method is all that matters
@evhub: Thanks for the response. The issue is not whether I'm trying to call the instance method from within the instance method (i.e. recursively). I'm actually not. I want the instance method to call an outside function of the same name. The issue is that I'm not allowed to do so. I could write the same code in Python (using classes, of course), and it works fine.