Open scolsen opened 1 year ago
re: (1.) the less we bundle with the compiler the easier it is to use it as a Carp in constrained environments. right now, we kind of force users to adopt our array and box types -- if we roll them entirely into the core lib instead, we'd be able to allow users to exclude them w/ no-core
re: (2.) code size matters in embedded. chances are C compilers would strip away unused C code anyway, we might as well help with that if we can by not generating unused C to begin with.
re: (3.) volatile and other qualifiers/attributes are important in embedded to ensure compilers don't e.g. eliminate unused bindings in register structs and such.
And another I thought of:
Also really curious to hear if @TimDeve has thoughts on this
Hey Scott,
I think these three improvement would be useful for sure.
copy
would also be quite useful. Another related thing is that managing core imports when using --no-core
is quite painful, you have to maintain your own Core.carp
and it breaks when the one in core gets updated. I was thinking a helper macro where you can pass the cores to omit might be nicer.On the library point I think the current implicit thing with main is kinda confusing, and explicit flag could be better. I also don't even remember what we generate then? An object file or a dynlib?
I also think all of these suggestions are great!
Perhaps the slightly extreme solution of not loading any core libraries by default could help? (I think Purescript does this..?) So it's all up to the user to decide what they bring in, except for stuff that is absolutely necessary for the compiler to start. One question then is what to do with the [ ]
syntax for array, since that is surely the nicest syntax. In a way it would make more sense if the built in (static) array used that one, and dynamic arrays switched to $[]
(or just a macro, like vec!
in Rust). And yes, lambdas should definitely not have to allocate by default (I have been thinking about that recently, and I think the fix is even simpler than what I tried to do in the feature branch. But I can make a comment there instead...)
Regarding code generation (and executable/library generation) I think a neat UX could be to provide something like emit-exe
/ emit-library
which would accept a module (or several) as an argument. In case of exe that module would have to have a main
defined (or you'd pass the function that should act as main). Then the code generator would walk all the dependencies of that module (or function) and only emit those.
Regarding point 3 – we do support this for definitions, right? (using meta data) But I guess it has to go in more places to be truly useful? Perhaps a separate issue with more details could clarify this.
Regarding point 3 – we do support this for definitions, right? (using meta data) But I guess it has to go in more places to be truly useful? Perhaps a separate issue with more details could clarify this.
Yes, we do! If I remember correctly though the UX around it wasn't perfect. I recall having to use const
qualifiers for a lot of stuff when making bindings to some Apple core libs and it was a bit awkward and didn't always work quite right for pointers, I think.
I'd like to use carp to generate some embedded code. This issue just tracks some quality of life improvements that I think would make that easier:
Will add further rationale in a bit.