-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Proposal: Inline Languages #13735
Comments
use PInvoke |
@ufcpp related yes, but not quite the same. I am reading this as an idea for effectively a fancy string type which works with some sort of compile time transform as defined by the In this proposal it looks like
the syntax In the case of a hypothetical While I would very much like to see some way to embed other languages in the same assembly as the one produced by compiling my C# code (currently achievable by ILMerge and certain IL weaving bits), I'm not so enthusiastic about this particular proposal. |
@bbarry , @bondsbw , beyond text strings for parsing, IDE features are possible for inline languages, for example syntax highlighting, IntelliSense, linting and corrections, code navigation, debugging and refactoring. Components like |
F#: public void PrintColor(Color color)
{
return
__fs
{
match color with
| Color.Red -> printfn "Red"
| Color.Green -> printfn "Green"
| Color.Blue -> printfn "Blue"
| _ -> ()
};
} |
Cosmos X#:
The idea is to have intellisense too for the inlined languages? |
While we're at it, class HelloWorld
{
static void Main()
{
__bf
{
++++++++[>++++[>++>+++>+++>+<<<<-]>
+>+>->>+[<]<-]>>.>---.+++++++..+++.
>>.<-.<.+++.------.--------.>>+.>++.
}
}
} |
Don't forget ook! |
And don't forget about languages that have mismatched curly braces, like J. 😀 |
@fanoI : Wonderful idea! absolutely love it |
Converge would be a nice example of a statically typed language with complex syntax (i.e. the exact opposite of Lisp) that nonetheless features both macros and internals DSLs in the style proposed here. |
So what is the fate of this proposal? For Cosmos will be really important to have the possibility to embed X# (x86 assembler) inside C# look what we have to do now: while instead with this proposal we could "simply" do:
I think that to not put too much burden on this the language team should give us a mechanism to make easy to embed languages in C# and maybe the "demo" one that they could implement is MSIL as I suppose themselves could have the necessity to call IL directly in some place. I add another language that could be interesting to embed in C#: IronPython actually to "compile" an IronPython fragment you have to pass it as string and as Python is so "boring" with the correct indentation having the possibility to write Python directly inside C# would be another plus of this proposal. Another thing: maybe this issue should be re-opened in csharplang? |
@fanoI I think this should definitely be re-opened in csharplang |
@AdamSobieski as you are the one that opened the issue here is better that are you to re-open it in csharplang, what do you think? |
This issue should be closed since you moved it to dotnet/csharplang#226. |
This proposal is similar but with different syntax: #34821 |
Proposal
I'd like to propose an idea for C# 8: inline languages. C and C++ have the
__asm
keyword which opens a new syntactical scope for inline assembly coding [1][2]. Proposed are such nested scopes in C# 8 for an open-ended set of languages.Inline languages are envisioned as implemented by .NET components and interoperable with integrated development environments, compilers and debuggers.
Modes of Operation
Three modes of operation are compatible with inline languages:
__asm
, generates program logicAdvantages
Examples
Scenarios
Ideas for inline language scenarios include:
__msil
,__xml
,__rdf
,__n3
,__sql
,__sparql
,__pls
,__srgs
,__ssml
,__antlr
,__grammar
,__prolog
References
[1] https://msdn.microsoft.com/en-us/library/45yd4tzz.aspx
[2] https://msdn.microsoft.com/en-us/library/4ks26t93.aspx
The text was updated successfully, but these errors were encountered: