oakc icon indicating copy to clipboard operation
oakc copied to clipboard

std vs. core

Open adam-mcdaniel opened this issue 5 years ago • 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.

adam-mcdaniel avatar Jul 29 '20 13:07 adam-mcdaniel

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

kevinramharak avatar Jul 29 '20 22:07 kevinramharak

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?

kevinramharak avatar Jul 29 '20 22:07 kevinramharak

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?

adam-mcdaniel avatar Jul 29 '20 22:07 adam-mcdaniel

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.

kevinramharak avatar Jul 29 '20 22:07 kevinramharak