Closed am-cid closed 3 months ago
sample text file ------------------------------------------------------------------- 1 | 2 | fwunc mainuwu-san() [[ 3 | num-Divide = Divide()~ 4 | pwint("halved: |num.halved(10)|")~ 5 | pwint("quartered: |num.quartered(10)|")~ 6 | ]] 7 | 8 | cwass Divide() [[ 9 | fwunc halved-kun(x-chan) [[ 10 | pwint(randomInt(1,2))~ 11 | pwint(sum())~ 12 | pwint(test())~ 13 | wetuwn(x / 2)~ 14 | ]] 15 | fwunc quartered-kun(x-chan) [[ wetuwn((halved(x) / 4))~ ]] 16 | fwunc test-chan() [[ wetuwn(1)~ ]] 17 | ]] 18 | fwunc sum-chan() [[ wetuwn(0)~ ]] 19 | ------------------------------------------------------------------- end of file
def main(): _num: _Divide = _Divide() print(String(f"halved: {_num._halved(Int(10))}")) print(String(f"quartered: {_num._quartered(Int(10))}")) class _Divide: def __repr__(self): return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})" def __str__(self): return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})" def _halved(self, _x: Int): _x: Int = Int(_x) print(self._randomInt(Int(1), Int(2))) print(self._sum()) print(self._test()) return (_x / Int(2)) def _quartered(self, _x: Int): _x: Int = Int(_x) return (self._halved(_x) / Int(4)) def _test(self): return Int(1) def _sum(): return Int(0) if __name__ == '__main__': # clear screen before executing import platform import os os.system('cls' if platform.system() == 'Windows' else 'clear') # declare globals main()
take note in halved(), all fn calls are assumed to be self calls even though its not defined in class scope
halved()
def main(): _num: _Divide = _Divide() print(String(f"halved: {_num._halved(Int(10))}")) print(String(f"quartered: {_num._quartered(Int(10))}")) class _Divide: def __repr__(self): return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})" def __str__(self): return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})" def _halved(self, _x: Int): _x: Int = Int(_x) print(_randomInt(Int(1), Int(2))) print(_sum()) print(self._test()) return (_x / Int(2)) def _quartered(self, _x: Int): _x: Int = Int(_x) return (self._halved(_x) / Int(4)) def _test(self): return Int(1) def _sum(): return Int(0) if __name__ == '__main__': # clear screen before executing import platform import os os.system('cls' if platform.system() == 'Windows' else 'clear') # declare globals main()
now properly differentiates whether an fn call inside class bodies are fn or method calls
source
transpiled before
take note in
halved()
, all fn calls are assumed to be self calls even though its not defined in class scopetranspiled after