Remix.run Logo
spankalee a day ago

Thanks!

So `items.[Iterable.iterator]()` is invoking a symbol-keyed method.

It's declared like:

    export interface Iterable<T> {
      static symbol iterator;

      [iterator](): Iterator<T>;
    }

    export MyArray<T> implements Iterable<T> {
      [Iterable.iterator]() { ... }
    }
This is similar to JS, where you can access properties of an object dynamically with [] notation, but Zena is static and doesn't have any reflection (yet) so the symbol has to be declared and statically resolvable, and Zena has operator overloading an a [] operator so we need a way to differentiate between symbol-keyed access from indexed access ([]), thus the o.[] syntax.

I do want to add pure functions, especially for compile time constants. I want to add a macro system that can either run pure functions (on the AST or IR, not sure yet) at compile time, or run arbitrary code sandboxed in a Wasm module.