I'm developing a custom utilities class and want it to be equally accessible in inflight and preflight modes. For example,
pub enum DatetimeFormat {
ISO,
MMYYYY,
YYYYMMDD_HHMM
}
pub class Util {
extern "./lib.js" static pub inflight toUtcString(date: std.Datetime): str;
extern "./lib.js" static pub inflight plus(date: std.Datetime, offset: duration): std.Datetime;
extern "./lib.js" static pub inflight minus(date: std.Datetime, offset: duration): std.Datetime;
extern "./lib.js" static pub inflight format(date: std.Datetime, format: DatetimeFormat): str;
extern "./lib.js" static pub inflight parse(date: str, format: DatetimeFormat): std.Datetime;
extern "./lib.js" static pub inflight formatMMYYYY(date: std.Datetime): str;
extern "./lib.js" static pub inflight parseMMYYYY(sd: str): std.Datetime;
extern "./lib.js" static pub inflight formatYYYYMMDD_HHMM(date: std.Datetime): str;
extern "./lib.js" static pub inflight parseYYYYMMDD_HHMM(sd: str): std.Datetime;
}
provides some additional computations for the std.Datetime class. All functions are defined as inflight which is their primary usage. However, I cannot use them in test setups since inflight functions cannot be called in the preflight context. This limitation leads to extra boilerplate code to be written.
Proposed Solution
I did not find anywhere in the documentation the convention of public inflight functions available directly from the library/module. Just found it in the Wing libraries code.
Make all inflight functions available in preflight (why not?), or provide a way to develop liftable classes, as it is done in the standard library. For example, I tried
pub class Util impl std.ILiftable {
...
}
but it did not help.
Implementation Notes
The implementation already exists for Wing standard libraries. Just need to make it accessible for potential contributors.
Component
Compiler
Community Notes
Please vote by adding a 👍 reaction to the issue to help us prioritize.
If you are interested to work on this issue, please leave a comment.
If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Discord.
Use Case
I'm developing a custom utilities class and want it to be equally accessible in inflight and preflight modes. For example, pub enum DatetimeFormat { ISO, MMYYYY, YYYYMMDD_HHMM }
pub class Util { extern "./lib.js" static pub inflight toUtcString(date: std.Datetime): str; extern "./lib.js" static pub inflight plus(date: std.Datetime, offset: duration): std.Datetime; extern "./lib.js" static pub inflight minus(date: std.Datetime, offset: duration): std.Datetime; extern "./lib.js" static pub inflight format(date: std.Datetime, format: DatetimeFormat): str; extern "./lib.js" static pub inflight parse(date: str, format: DatetimeFormat): std.Datetime; extern "./lib.js" static pub inflight formatMMYYYY(date: std.Datetime): str; extern "./lib.js" static pub inflight parseMMYYYY(sd: str): std.Datetime; extern "./lib.js" static pub inflight formatYYYYMMDD_HHMM(date: std.Datetime): str; extern "./lib.js" static pub inflight parseYYYYMMDD_HHMM(sd: str): std.Datetime; } provides some additional computations for the std.Datetime class. All functions are defined as inflight which is their primary usage. However, I cannot use them in test setups since inflight functions cannot be called in the preflight context. This limitation leads to extra boilerplate code to be written.
Proposed Solution
Implementation Notes
The implementation already exists for Wing standard libraries. Just need to make it accessible for potential contributors.
Component
Compiler
Community Notes