2018-07-12 | Paul Boddie | file changeset files shortlog | Support trailing data after attributes in objects, employed by float instances to store their double-precision numeric data which needs more space than single attributes on some systems. In order to initialise such instances statically, specific object types must be indicated instead of the generic __obj type. This then requires casting to __ref of direct references to objects. Added an underflow error. Added initial testing of floating point numbers. | trailing-data |
paul@46 | 1 | class C: |
paul@46 | 2 | def __init__(x, y, z): # no explicit self |
paul@46 | 3 | self.x = x |
paul@46 | 4 | self.y = y |
paul@46 | 5 | self.z = z |
paul@46 | 6 | |
paul@46 | 7 | def c(): |
paul@46 | 8 | return self.x |
paul@46 | 9 | |
paul@46 | 10 | class D(C): |
paul@46 | 11 | def d(): |
paul@46 | 12 | return self.y |
paul@46 | 13 | |
paul@46 | 14 | class E(D): |
paul@46 | 15 | def c(): |
paul@46 | 16 | return self.z |
paul@46 | 17 | |
paul@46 | 18 | c = C(1, 2, 3) |
paul@46 | 19 | d = D(1, 2, 3) |
paul@46 | 20 | e = E(1, 2, 3) |
paul@46 | 21 | |
paul@214 | 22 | print c.c() # 1 |
paul@214 | 23 | print d.c() # 1 |
paul@214 | 24 | print e.c() # 3 |
paul@214 | 25 | print d.d() # 2 |
paul@214 | 26 | print e.d() # 2 |