phylanx icon indicating copy to clipboard operation
phylanx copied to clipboard

Append is broken.

Open rtohid opened this issue 6 years ago • 1 comments

from phylanx import Phylanx

@Phylanx(debug=1)
def test_append():
    a = []
    append(a, 1)

    return a

print(test_append())

expecting [1], getting []:

define(
    test_append,
    lambda(
        block(
            define(
                a,
                list()
            ),
            append(a, 1),
            a
        )
    )
)
[]

rtohid avatar Mar 30 '19 14:03 rtohid

@rtohid I think the problem is that PhySL objects are never changed in-place. The following should work as expected:

from phylanx import Phylanx

@Phylanx
def test_append():
    a = []
    a = append(a, 1)
    return a

print(test_append())

I'm not sure whether we should do the corresponding transformations in the frontend (i.e. transforming append(a, 1) into a = append(a, 1)). What do you say?

hkaiser avatar Mar 30 '19 23:03 hkaiser