Skip to content
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

Language Support: C# Macros (Compilation time methods) #1911

Closed
prasannavl opened this issue Apr 10, 2015 · 4 comments
Closed

Language Support: C# Macros (Compilation time methods) #1911

prasannavl opened this issue Apr 10, 2015 · 4 comments

Comments

@prasannavl
Copy link

Macros are extremely powerful, but can introduce unnecessary complications, when not done right.
Currently, the only way to have this level of functionality is to do messy post-compile IL rewrites, and/or Debug conditionals to a certain extent, for conditional codes.

Addition of macros in the way its expressed in Rust-Lang where the evaluations happen during compile time, and produce code could be extremely powerful, and could be realized neatly with Roslyn. Rust-Lang expresses them very succinctly as a part of the language itself (almost in-differentiable from calling methods)

This could potentially replace all mixin tweaks currently used, but without any of the run time-performance hit.

I haven't thought much on the implementation, but if this seems to be an area of interest for the core team, implementation discussions here could be started off here. Meanwhile, in comparison with Rust itself which provides a clean implementation that works with pattern matching at its crux, the key detail would be in how the handoff to Roslyn happens, and how the resulting tree is created by Roslyn with type-safety.

@AdamSpeight2008
Copy link
Contributor

@prasannavl
Take a look over issue #174 Template Functions.

@prasannavl
Copy link
Author

@AdamSpeight2008 Was a bit disappointed when my search for macros in GitHub issues yielded none. Function templates seem appropriate! Nice, shall give it a thorough read soon.

@dsaf
Copy link

dsaf commented Feb 1, 2016

Some inspiration could be drawn from Nemerle - a fringe but stable .NET language:

https://github.com/rsdn/nemerle/wiki/Macros-tutorial

https://github.com/rsdn/nemerle/wiki/Nemerle-macros-intro

This is a relatively large repository using Nemerle - Nitra - an upcoming awesome language workbench by JetBrains: https://github.com/JetBrains/Nitra

@gafter
Copy link
Member

gafter commented Mar 20, 2017

We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages.

See also dotnet/csharplang#107

@gafter gafter closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants