They are compiled as local variables defined in an implicit
scope surrounding the class. This has the right semantics and,
better, means that there's no VM support needed for them.
They're purely syntax sugar.
Class symbol tables now grow on demand, and the relevant
instructions take 16-bit arguments. There's a small perf hit
for this, but only a few percent, which is good.
- Primitives can now signal an error.
- An error prints a callstack and ends the current (and right
now only) fiber.
- Arithmetic operators error if the operand is not a number.
- Real error for method not found.
- Associate source file name, and method names with functions.
- Debug line number info for functions.
Unfortunately, this regresses perf on fib about 15%, mostly
because of the better checking in arithmetic ops.
There's still a bunch of clean up to do, but this is a big step
in the right direction.
Added ".." and "..." infix operators. Num implements them to
return Range objects. Those in turn implement the iterator
protocol, so now numeric for loops are easy:
for (i in 1..10) { ... }
I also cleaned up the Wren benchmarks to use this.
In the process, I discovered the method_call benchmark really
just showed loop peformance, so I unrolled the loops in all of
the languages to stress method calls.
They are now invoked like "new Foo".
Also, superclass constructors are now much less semantically
and syntactically weird. Since the instance is created before
any constructor is called, there's no point in time where the
instance isn't there.
This also fixes a bug where constructors weren't being bound
correctly, and eliminates some unneeded instructions when
compiling ifs.
I also tweaked the other method_call languages to match Wren's.
Since Wren needs to do a super call to get to the parent _count,
the other languages do now too.
This is nice too because it means we're benchmarking super
calls.