Commit Graph

17 Commits

Author SHA1 Message Date
K. Lange
a4a4da70df Fixup more kwargs stuff, need to pop values for defaults 2021-01-05 19:01:26 +09:00
K. Lange
2f78ae8770 maybe support __eq__? 2021-01-05 17:41:32 +09:00
K. Lange
c8758c9ffb Add tuple type to store immutable lists 2021-01-05 11:38:11 +09:00
K. Lange
2ee154ecf7 Add argument expansions... 2021-01-03 18:13:17 +09:00
K. Lange
76e70b79d0 Add default argument values.
Unlike in Python, I'm taking the approach of evaluating these at function
call time rather than definition time. Assigning things like empty lists/dicts
to default arguments has always been a ridiculous thing in Python, and I don't
want to make that mistake. I'm pretty sure Python only continues to do that
because it was something they didn't want to break for backwards compatibility
reasons even in Python 3.
2021-01-03 12:32:04 +09:00
K. Lange
310cbe4e70 Don't explode when trying to print a null bound method 2021-01-03 09:19:38 +09:00
K. Lange
b676df69da Add method decorators
This required a new approach for handling function arguments.

Methods remain the same: the callee object is on the stack and positioned
to be "argument 0". Non-methods have changed so that "argument 0" is the
first argument, with the function still remaining before that. When a
non-method is called, we track this fact so that we can continue to restore
the stack to the correct height to get rid of the function. This allows
a method decorator to be defined exactly like it would be in Python

def methodDecorator(func):
    def wrappedMethod(instance, someOtherArg):
        print "Do something with the arg:", someOtherArg
        func(instance)

class Foo():
    @methodDecorator
    def func():
        print "I only take an implicit self:", self

let f = Foo()
f.func("but that other arg is needed")
2021-01-03 08:43:32 +09:00
K. Lange
b1b747b234 Some improvements to debug output before I move on to a marshalling format 2021-01-02 13:42:07 +09:00
K. Lange
b42844f842 Fully internalize list+dict core methods and implement invokes for getters/setters 2021-01-01 20:52:18 +09:00
K. Lange
ae2e2be15d do something more straightforward and useful for methods on non-objects 2021-01-01 16:02:16 +09:00
K. Lange
a0d52a61f2 add an exception mechanism 2020-12-29 11:00:12 +09:00
K Lange
e9261a2f56 change size of integers to long 2020-12-28 16:32:40 +09:00
K. Lange
ae2b00bcfa int32_t is long int on toaru? I should probably fix that 2020-12-28 21:08:55 +09:00
K. Lange
0f508c38dc Add support for iterators 2020-12-28 13:35:02 +09:00
K. Lange
aab01f01f7 Finish up chapter 22, local variables; fix up indentation-based scoping 2020-12-26 18:39:29 +09:00
K. Lange
417637ef21 hash tables (which should work with any object as keys?) and string interning from ch 20 2020-12-26 14:33:34 +09:00
K. Lange
14aeea5f5b through chapter 19 of Crafting Interpreters 2020-12-26 09:32:21 +09:00