Skip to content
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

Provide lifting support for custom computation utilities/classes. #6741

Open
asterkin opened this issue Jun 18, 2024 · 2 comments
Open

Provide lifting support for custom computation utilities/classes. #6741

asterkin opened this issue Jun 18, 2024 · 2 comments
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl

Comments

@asterkin
Copy link

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

  1. 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.
  2. 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.
@asterkin asterkin added needs-discussion Further discussion is needed prior to impl ✨ enhancement New feature or request labels Jun 18, 2024
@Chriscbr
Copy link
Contributor

Related: #435

Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Sep 22, 2024
@Chriscbr Chriscbr removed the Stale label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

3 participants