I would like to have also write1(), write2(), read1(), and read2() (or alike)
This is exactly what I hope to avoid - it is basically all duplicated code, when a single read and write function that take an array will handle everything.
If you want these functions, maybe add another module that implements them on top of the basic read/write functions.
the API with writing without passing size(limit) and reading with size for bare metal operations looks to me as inconsistent
It's not really - just saving space. If you're doing write(array) why should you have to write write(string, string.length)? It's not the same as C where you're dealing with just a pointer - the length of the array/string is an integral part of it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
This is exactly what I hope to avoid - it is basically all duplicated code, when a single
read
andwrite
function that take an array will handle everything.If you want these functions, maybe add another module that implements them on top of the basic read/write functions.
It's not really - just saving space. If you're doing
write(array)
why should you have to writewrite(string, string.length)
? It's not the same as C where you're dealing with just a pointer - the length of the array/string is an integral part of it.