compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Request: modules

Open siraben opened this issue 5 years ago • 7 comments

Thanks for your work on this, we've been actively working on a fork of this compiler that bootstraps it all the way from a 357 byte binary on various architectures. One feature that is missing in particular is modules, which would allow separation of code into different files.

It's non-critical for our work but if added would greatly help, especially since we plan to build a Scheme interpreter on top of this. How complex would it be to add?

siraben avatar Dec 22 '20 15:12 siraben

I've been wanting to add modules for a while. I've been holding off because I wanted to explore a little, and try implementing Agda-style modules for example. But perhaps it's best just to get something simple working first.

My experimental "precisely" compiler supports #include directives, which I use to split code across multiple files. I'll see if it makes sense to document it and make it a bit more official.

blynn avatar Feb 21 '21 09:02 blynn

On closer inspection, it looks like "crossly" was my first compiler to support #include. It's just undocumented.

So if you manage to get "crossly" working, you can temporarily use includes to get a poor man's modules.

blynn avatar Feb 21 '21 12:02 blynn

Yeah, we have blynn-compiler compiling all the way to precisely. Thanks!

siraben avatar Feb 21 '21 12:02 siraben

I added modules, though there are many caveats at present. It's based on "methodically", and I hope to work my way back up to "crossly" via modules. https://crypto.stanford.edu/~blynn/compiler/module.html

blynn avatar Mar 14 '21 13:03 blynn

Are features like qualified imports and hiding planned?

siraben avatar Sep 15 '21 17:09 siraben

I hope to get around to it some time.

blynn avatar Sep 20 '21 17:09 blynn

I have a rough implementation of qualified imports and hiding, though modules in general are rough around the edges.

blynn avatar Nov 05 '21 21:11 blynn