chasm icon indicating copy to clipboard operation
chasm copied to clipboard

Implement intrinsics in chassembly where possible

Open Earthcomputer opened this issue 2 years ago • 0 comments

I propose that we should implement intrinsic functions in chassembly whenever it is possible to do so. Currently, some intrinsic functions (like from_entries) are possible to reimplement in chassembly, while others (like file_bytes) are not. Please note that just because the function is implemented in chassembly, that does not mean that the chassembly implementation is actually run, and that an equivalent Java implementation isn't run instead. The meaning of "intrinsic" is simply that the interpreter is allowed to treat the function as special.

Doing this would have the following advantages:

  • Makes adding new intrinsic functions easier.
    • No new Java code needed.
    • Doesn't need to be added to the formal chassembly specification when it is written.
  • Provides an easy to access reference implementation for intrinsics that are implemented in both chassembly and Java.
  • Expands the scope of intrinsics we can add. Currently we are very hesitant to add new intrinsics, I'm hoping that doing this will allow for more of a standard-library-esque feel to them, without some of the downsides this would have previously meant.
  • 3rd party analysis tools don't need to implement every intrinsic themselves.

Earthcomputer avatar Jan 31 '23 21:01 Earthcomputer