-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFI right now is very bad #10
Comments
Would |
The |
Those flags would be great features to add. The extern flag would be a great addition. Conditional compiling would also be really useful. |
Hmm, that's an interesting thought. I assumed that whichever platform the compiler is running on would be the platform the generated code is running on, but I see that MIGHT not be true in niche places such as cross compilation or when compiling to targets without an OS. The constants are intended to help with operating specific information, like using different file extensions based on the operating system, or using different code to get the user's home directory. I think you make an interesting point about needing to know the operating system at runtime. Maybe the compile time constants regarding the operating system should remain, and standard library functions (NOT added to the core VM instruction implementation files) should be added to determine the operating system that the code is running on. |
I also see some problems with the |
Well my target has no OS for example. So it is pretty much already cross compiling to a target with no OS. I understand its intent, but i assume most languages state the target platform instead of the compiling one. For example my target the keyboard has no |
I don't think it's that much of a stretch to require the user to use a I do agree with you about the implementing the retrieval of information about the programs platform at runtime, though. |
Right, I just checked it and never realised C works like that. So the VM implementation (and the code generated to kickstart it) would be the runtime and required? Any 'default' functions and data would be the standard library and optional? I guess it is easy to document and mention when introducing people to the language. |
Yes, I think having both flags would definitely work. With the |
In PR #20, all of the aforementioned flags except |
I like the idea of both flags being optional. As with constants id suggest to see how it evolves. |
Finding it somewhat weird that you have C and Go FFI but not Rust... |
Things in the ffi branch need to change drastically before I can merge it. I really dislike having to use the command line to include FFI files. I think it's incredibly inelegant, and I think the only valid solution is to add a few new flags to the language.
#[no_std]
extern
flag in the user's source code.#[extern("foreign_file.*")]
#[error("Error message")]
#[if(const_expr) { // Oak code here }]
#[if(const_expr) { // Oak code here } else { // Oak code here }]
These flags don't really help without a few constants to help, though.
TARGET
Target
impl in the HIR stage of compilation. Each target will have their own character constant that represents that target. For example, C's target value might be'c'
, and Golang's might be'g'
.IS_STANDARD
int
values, for example, would set this flag to be false.ON_WINDOWS
ON_MACOS
ON_LINUX
ON_NIX
ON_NON_NIX
OAK_MAJOR_VERSION
OAK_MINOR_VERSION
OAK_PATCH_VERSION
DATE_DAY
DATE_MONTH
DATE_YEAR
These constants are pretty much on par with C predefined macros and Rust's
cfg!
macro. This should give users enough information to do some serious compile time hacking.The text was updated successfully, but these errors were encountered: