These are chat archives for evhub/coconut

Jun 2017
Evan Hubinger
Jun 05 2017 03:35
@mpjoseca_twitter Happy to know that --target 3.3 solved your problem, though for future reference it'd be great to figure out what the issue was so I can fix it on all targets. Theoretically, Python should allow you to import the same module twice, so the fact that Coconut imports sys in addition to your code shouldn't be a problem. Do you have a traceback I could look at?
Pierre-Antoine Champin
Jun 05 2017 12:41
Hi all, I'm a newbie in coconut, and I can't figure out why the following function does not work:
def partition(items, pivot, lprefix=[], rprefix=[]):
    case items:
        match [head]::tail:
            if head < pivot:
                return partition(tail, pivot, [head]::lprefix, rprefix)
                return partition(tail, pivot, lprefix, [head]::rprefix)
        match []::_:
            return lprefix, rprefix
I get the following exception:
coconut.exceptions.CoconutSyntaxError: variable names cannot start with reserved prefix _coconut (line 1)
return partition(tail, pivot, _coconut.itertools.chain.from_iterable((_coconut_lazy_item() for _coconut_lazy_item in (lambda: [head], lambda: lprefix))), rprefix)
Note that I "solved" the problem by replacing :: by + in the first two return statements, but IIUC it forces my iterators to be converted to lists, which is not what I want...
Pierre-Antoine Champin
Jun 05 2017 15:17
Furthermore, even if I did something wrong, the exception is really unhelpful: I didn't use the reserved _coconut prefix... ;-)