You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use clause describe relationships between "features". In Ribbit, a feature describes some piece of code that needs to be added inside the output of the compiler (a specialized rvm with the embedded bytecode). This can take the form of adding a primitive into the primitive table, an importation to a needed package or the definition of a conversion function. The example you have here is quite confusing because the feature "js/node/fs" is actually not needed for this primitive (it's a bug). Here is a better example to understand the use clause :
Here, a comment between @@( and )@@ tells the compiler that the line fs = require("fs") must be included only if the feature js/node/fs is activated. Note that it will also be included if the features "##getchar" or "##putchar" is activated.
The second feature refers to this par of the code inside the rvm.js:
// @@(feature scm2str
scm2str = (r) => {
let f = (c) => (c===NIL?"":String.fromCharCode(c[0])+f(c[1]));
return f(r[0]);
};
// )@@
This defines a conversion between scheme (Ribbit) strings and JavaScript strings.
If we look back at the primitive we originally had, we see that the primitive uses (inside the string) the fs module and the conversion function. The use clause tells the compiler to include the two pieces of code inside the rvm when generating the code. This is needed by the primitive because without these pieces of code, the primitive cannot work properly. If you want more info about this, we have a paper on it. The use clause is discussed in section 4 : https://www.iro.umontreal.ca/~feeley/papers/OLearyFeeleyMOREVMS23.pdf
If you want to fix the prim-io file of the js host by removing the unnecessary use clauses, I'll accept the PR right away ! I think some of the primitives inside this file are affected. Don't forget to target the PR to the dev branch if you do it.
Hi
could you explain how ‘use’ works?
https://github.com/udem-dlteam/ribbit/blob/dev/src/host/js/lib/prim-io.scm
`
The text was updated successfully, but these errors were encountered: