wing icon indicating copy to clipboard operation
wing copied to clipboard

Support Indexed Macro Args

Open hasanaburayyan opened this issue 2 years ago • 3 comments

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 use indexed args in wingc macros

/**
 * Adds or updates an entry in a Map object with a specified key and a value.
 * @macro $self$[$args[0]$]=$args[1]$
 */
public set(key: string, value: T1): void {
  key;
  value;
  throw new Error("Macro");
}

Use Cases

This is currently achievable by doing a inline function with macros like so:

   /**
	* @macro ((obj, args) => { obj[args[0]] = args[1]; })($self$, [$args$])
   **/

Implementation Notes

No response

Component

No response

hasanaburayyan avatar Feb 24 '23 11:02 hasanaburayyan

This is a good idea, though I feel like brackets might makes the macro syntax seem more expression-based or smart than it really is? Not sure...

I wonder if we should try and collect more use cases before making the macro language too complex, given it's possible that macros could become part of the language formally at some point. I feel like they deserve some care given that they're an explicit leak into our JS target code

Chriscbr avatar Feb 24 '23 18:02 Chriscbr

Hi,

This issue hasn't seen activity in 60 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[bot] avatar Apr 26 '23 06:04 github-actions[bot]

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[bot] avatar May 09 '24 06:05 github-actions[bot]