mita icon indicating copy to clipboard operation
mita copied to clipboard

Native checked functions without arguments

Open wegendt-bosch opened this issue 6 years ago • 3 comments

Currently only checked native functions with at least one argument can be imported, for example

Retcode_T foo(void* unused) {}

We should enable importing checked functions without any arguments, like

Retcode_T bar(void) {}

This would allow easier reuse of library functions.

I propose the following syntax:

native checked fn bar(void): void header "bar.h";

wegendt-bosch avatar Oct 29 '18 10:10 wegendt-bosch

Mita's function convention is to have a void* pointer for void functions. The signature Retcode_T bar(void) {} violates this convention and thus cannot be called in checked style. This is intentional.

One can call declare and call void checked functions using native checked fn bar(): void header "bar.h".

csweichel avatar Oct 30 '18 13:10 csweichel

Well, a lot of native Retcode_T-void-functions don't have this though. Sure, it violates our style, but to adhere to it means that users need to write a wrapper for each of those functions, which is cumbersome and feels unneccessary.

I get that this is intentional, however it seems like an ultimately bad intentional decision since it is justified mostly by "it makes the compiler easier".

wegendt-bosch avatar Oct 31 '18 08:10 wegendt-bosch

Furthermore not even we always adhere to this standard, for example:

Retcode_T SetupTime(void);

Retcode_T EnableTime(void);

Retcode_T EveryHandleEvery10Second1_Enable(void);

and many more.

wegendt-bosch avatar Oct 31 '18 08:10 wegendt-bosch