winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.03k stars 196 forks source link

Add Macro Support For Getter and Setter Methods #1658

Open hasanaburayyan opened 1 year ago

hasanaburayyan commented 1 year ago

Community Note

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.

Feature Spec

I want to be able to add a macro to a getter/setter method.

/**
 * Returns the number of elements in the map.
 * 
 * @macro Object.keys($self$).length
 */
public get size(): number {
  throw new Error("Macro");
}

Use Cases

Solves issue where we have to use normal methods like size() rather than simply invoke size on plain java objects. As done in this PR: https://github.com/winglang/wing/pull/1653/files#diff-02245bbbc2eb597dd86d8484abff67768e1e36b6af074525abb3fa3c1113ef32

Implementation Notes

No response

Component

Compiler

hasanaburayyan commented 1 year ago

Once this is implemented we should fix the Map API back to size rather than size() which I changed as part of: https://github.com/winglang/wing/pull/1653

staycoolcall911 commented 1 year ago

Once this is implemented we should fix the Map API back to size rather than size() which I changed as part of: #1653

I think we should actually keep it uniform across our container types, so it should be .len.

github-actions[bot] commented 5 months ago

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!