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

Add Macro feature to resolve variables bound with a let #938

Jand42 opened this Issue Apr 16, 2018 · 0 comments


2 participants

Jand42 commented Apr 16, 2018

In an expression like let y = x + 1 in macroedFunction y, the macro defined on macroedFunction will only see y as the argument expression, with no way to see what it is bound to. It would help some use cases (for example UI templating type provider would be able to allow .V syntax) if this would be possible.

Proposed changes:

  • MacroCall/Ctor record would have a new field BoundVars with type IDictionary<Var, Expression>. It would contain those let-bound variables in the scope of the macro call that are only used once (otherwise, macro incorporating them would not be safe).
  • MacroResult union would have a new case MacroUsedBoundVar that would cause the translator to remove the outside let and just keep its inner value. It would be the macro implementation's responsibility to handle expression purity and not using the removed variable in it's output.

@Jand42 Jand42 added the proposal label Apr 16, 2018

@Jand42 Jand42 added this to 4.3 in Releases Apr 16, 2018

@Tarmil Tarmil closed this Jun 26, 2018

@Tarmil Tarmil added the label Jun 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment