WhileyCompiler icon indicating copy to clipboard operation
WhileyCompiler copied to clipboard

Std Native Method Implementations

Open DavePearce opened this issue 3 years ago • 1 comments

Need to figure this out in conjunction with the standard library.

DavePearce avatar Jun 01 '22 03:06 DavePearce

One problem here is how to represent File. Some points:

  • (Rust / C) The obvious choice is to represent File as a fixed-width record. This follows Rust, where File is a struct albeit with hidden fields.
  • (JVM) The above choice is difficult (impossible?) on the JVM because you must represent it as an object, such as FileDescriptor or RandomAccessFile or similar. These don't exist in Whiley, so you're forced to hide them in an open record.

Not sure how to reconcile this. One possibility is perhaps to allow for a native type fd which is hidden from the user. Then, on C/Rust platforms this is just a uint whilst on Java it is something else altogether.

Yet another approach on the JVM is to add a second level of indirection. Basically, an array of FileDescriptor objects which can be indexed into. I suppose that would work at least.

DavePearce avatar Jun 01 '22 03:06 DavePearce