BookOwl / nustack

Nustack is a stack-oriented concatenative programming language with support for high-level modular programming and Python integration.
MIT License
12 stars 2 forks source link

Compile to bytecode? #12

Open jeandrek opened 8 years ago

jeandrek commented 8 years ago

This (and a bytecode interpreter) will be a big job, so if you don't want to do it just ignore this :package:

jeandrek commented 8 years ago

I wonder if it is possible to compile to pyc and piggyback of Python's bitcode interpreter...

BookOwl commented 8 years ago

Actually, a trivial implementation would be to just save the parsed token list to a file using the pickle module. Then the bytecode interpreter would really be just loading the pickle file and passing it to the normal evaluator. I have a feeling that's not what you were thinking of though...

BookOwl commented 8 years ago

The whole point of creating this is to learn, so I would be open to doing this the proper way.

jeandrek commented 8 years ago

The point of a bytecode interpreter is speed. Pickling the AST and then caching it may improve startup speed (depending on how long it takes to un-pickle vs parse) but not execution speed (? pretty sure).

But no, that's not what I was talking about :stuck_out_tongue: I meant compiling it to a low-level bytecode that can be interpreted fast (without parsing). (And it could be cached.)

Either will probably have advantages.