Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Tag AST nodes for pattern recognition #789
tag AST nodes for pattern recognition
Code translates to an AST, before compiling down to ILASM. One way of putting code aside for special treatment is to place it in a quotation. Another technique is through tagging regular code in a more granular way, so that after scanning the resulting AST, you can opt to do something different.
OCaml allows "tagging" of language constructs. Tagging doesn't do anything except help make more informed pattern recognition of the AST tree possible.
An existing way of approaching this problem in F# is to maybe have disguised identity functions ie. the name of the function could_be_a_special_tag. There may be places that syntactically this will not work though.
Often the .NET pattern is to tag classes and structure with attributes, but this approach is often too cumbersome if you seek to be more language-oriented.
Pros and Cons
The advantages of making this adjustment to F# are more flexible pre-compilation choices, for special cases.
It's a relatively low-risk suggestion. The tag itself doesn't have any extra functionality. It's just an identifier for custom Compiler Services.
The disadvantages of making this adjustment to F# are ...
The typical arguments about hurting language adoption through increasing the language surface area, I suppose. There's the can we trust people to use this feature responsively discussion, too.
Estimated cost (XS, S, M, L, XL, XXL): S
Safe At Any Speed
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
I don't really follow what it is you're requesting here. Do you have a concrete example of something that would be made possible or easier? When you talk about OCaml, I assume you mean the