STEllAR-GROUP / phylanx

An Asynchronous Distributed C++ Array Processing Toolkit
Boost Software License 1.0
75 stars 76 forks source link

Feature: Use decorator within a class #1256

Open diehlpk opened 4 years ago

diehlpk commented 4 years ago

I was wondering if we can get this example to work in a near future

from phylanx import Phylanx

class test:

    n = 0

    @Phylanx
    def __init__(self,n):
        self.n = n

    @Phylanx
    def do(self,m):
        self.n += m 

if __name__ == "__main__":

    t = test(10)

    t.do(10) 

Or at least make some comment in the Readme that this is not supported yet

hkaiser commented 4 years ago

This is not supported (yet), as we don't support classes at all.

hkaiser commented 4 years ago

We should implement this instead:

from phylanx import Phylanx

@Phylanx
class test:

    n = 0

    def __init__(self,n):
        self.n = n

    def do(self,m):
        self.n += m 

if __name__ == "__main__":
    t = test(10)
    t.do(10)