phylanx icon indicating copy to clipboard operation
phylanx copied to clipboard

Can't use function in argument to "for in"

Open stevenrbrandt opened this issue 5 years ago • 2 comments

This code fails with a KeyError.

from phylanx import Phylanx

@Phylanx
def arr():
    return [1,2,3]

@Phylanx
def use_arr():
    for a in arr():
        print(a)

use_arr()

However, simply moving the arr() function out of the loop causes it to work

from phylanx import Phylanx

@Phylanx
def arr():
    return [1,2,3]

@Phylanx
def use_arr():
    f = arr()
    for a in f:
        print(a)

use_arr()

stevenrbrandt avatar Feb 12 '20 23:02 stevenrbrandt

@rtohid yet another problem that could use your expertise. Would you be able to have a look?

hkaiser avatar Feb 13 '20 03:02 hkaiser

Currently, functions as iteration spaces are not supported, except for range and prange: https://github.com/STEllAR-GROUP/phylanx/blob/ee2487275ad5b653ad0e5fae1e882a0f4404c6a5/python/phylanx/ast/physl.py#L955

I'm working on a cleaner way to generate and analyze code, https://github.com/rtohid/phyflow/blob/refactor/flow/ir/base.py.

rtohid avatar Feb 13 '20 16:02 rtohid