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

Function Annotations #65

Open
BobVarioa opened this issue Jun 9, 2024 · 0 comments
Open

Function Annotations #65

BobVarioa opened this issue Jun 9, 2024 · 0 comments
Labels
A-builtins area: builtins S-large size: large T-feature type: feature T-performance type: performance

Comments

@BobVarioa
Copy link
Contributor

BobVarioa commented Jun 9, 2024

Motivations:

  • Right now, there isn't really any way to give information to the compiler about various aspects of a method. I ran into this more specifically in Memory improvements + Type analysis #56 with the return type of the Date constructor, a return type based on new.target, not exactly a union type but moreso a type that requires a condition to be true.
  • This is but one example though, for instance, we use hacks like $get to denote accessors for length or size, this could remedy that.

This could likely be implemented in various ways, but I imagine the following:

@Constructor("Date")
@Returns<string>
function Date() {
  // ...
}

or

@Accessor("size")
@Inline 
@Pure 
function __Set_prototype_size() {
  // ...
}

I would imagine that some of these will become less necessary with time, for example when objects are introduced, but something like @Inline or @Pure could be really helpful hints to the compiler

@CanadaHonk CanadaHonk added A-builtins area: builtins S-large size: large T-feature type: feature T-performance type: performance labels Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builtins area: builtins S-large size: large T-feature type: feature T-performance type: performance
Projects
None yet
Development

No branches or pull requests

2 participants