Forthon icon indicating copy to clipboard operation
Forthon copied to clipboard

Master setobject

Open jguterl opened this issue 3 years ago • 2 comments

add setpyobject method in Forthon to be able to alias a Forthon object into a class (ease the dumping/loading of data)

Example with 'face' as Forthon oject:

class test(): def init(self): for v in face.varlist(): setattr(self.class,v,property(self.getter(v), self.setter(v), face.getvardoc(v))) @staticmethod def getter(varname): def getfaceobj(self): return face.getpyobject(varname) return getfaceobj @staticmethod def setter(varname): def setfaceobj(self,vv): return face.setpyobject(varname,vv) return setfaceobj

jguterl avatar Dec 04 '21 04:12 jguterl

I don't think that this routine is needed. You can do

def setfaceobj(self,vv):
  return setattr(face, varname, vv)

This ends up calling the same routine Forthon_setattro.

dpgrote avatar Dec 07 '21 00:12 dpgrote

Yes right

On Mon 6 Dec 2021 at 16:56 David Grote @.***> wrote:

I don't think that this routine is needed. You can do

def setfaceobj(self,vv): return setattr(face, varname, vv)

This ends up calling the same routine Forthon_setattro.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dpgrote/Forthon/pull/30#issuecomment-987454776, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEESMZCFGYZGQFJTI3IM67DUPVLTRANCNFSM5JLEBWCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jguterl avatar Dec 07 '21 05:12 jguterl