adam-mcdaniel/oakc

std vs. core

Opened this issue · 4 comments

Right now, there is a bit of confusion about the distinction between the standard library and the core VM implementation.

The core VM implementation should be all that a program needs to compute anything. The compiler should NOT include functions for IO in the implementation of the core.

Each Target should implement a std_library method, which returns foreign code that implements the standard library.

I would suggest to advise implementations to return a #[extern] directive? That should be enough for most implementations and keep the rust implementation clean.

An issue I am having with trying to seperate these is that the panic() feature currently writes output to 'stdout' on what goes wrong. Great for debugging but it depends on duplicate logic implemented in my standard library. What would be the spec for handling runtime errors?

Hmm, I hadn't considered how panic should be implemented. I think that panic info should be written to stdout for convenience sake, but I'm not really sure if there might be a better solution. On platforms that cant support stdout, they should just exit with an error return code, though.

I'm not really convinced of a specific idea yet; what do you think?

Well, I think most runtimes have some form of error reporting. That would be a great start. I think requiring it to exit with an error code fairly standard. Having a few documented exit codes also seems like a good idea. Making it optional (but best practice) to write a human readable message to stderr (or stdout if there is no stderr) seems like a sane thing to do for now. That would leave room for debugging tools to give as much info as possible once those are introduced. I'm asking because having a standardized way of dealing with runtime errors seems like a smart thing to do when targeting as much environments as possible.