Skip to content

[Feature] Implement basic Async Function API #727

@Luna-Klatzer

Description

@Luna-Klatzer

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

Important: This does not propose the implementation of the Promise API built into JS, but rather the basic high-level async API allowing the designation and calling of Async functions, such as built-in fetch()

As Kipper is currently only running in sync mode, it is unable to perform proper non-blocking web requests which await the response of a given web server. To fix this, Kipper should start its async implementation with a simple async def, -> Promise<T> and await T() syntax and compiler support. These functions will as expected return a standard Promise, which then can be called using await. Calling an async function with await is therefore not necessary and can be stored in a variable if required.

Exact behaviour / changes you want

  • Implement the async prefix keyword for function definitions, which enables an enforced compiler rule that the function must return a Promise<T>.
  • Implement the await expression which takes in any expression and attempts to call it (error if it's not an awaitable/Promise)
  • Implement the Promise<T> as a basic empty compiler type, which for now only contains the most basic parameters and data, as well as allows the compiler to properly recognise whether an await is valid.

Metadata

Metadata

Assignees

Labels

featureNew feature or enhancementquestionFurther information is requested

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions