These are chat archives for evhub/coconut

Jul 2018
David O'Gwynn
Jul 19 2018 15:58

@evhub I'm running into an odd (to me, at least) behavior with combining data types, their methods and outside functions:

>>] coconut
Coconut Interpreter:
(type 'exit()' or press Ctrl-D to end)
>>> data X:
            def function(self, arg):
                return function(self, arg)

>>> def function(x is X, arg):
            return arg

>>> X().function(1)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 33, in tail_call_optimized_func
  File "<string>", line 7, in function
NameError: name '_coconut_recursive_func_0' is not defined

It's confusing to me because within the context of an instance method, you must refer to the X method function via self.function, otherwise function is resolved outside the method context.

Am I not understanding the design of data types?

Thanks much.

David O'Gwynn
Jul 19 2018 16:06
Just to be clear and explicit, this issue is resolved if the function and the method have different names.