question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Inline Languages

See original GitHub issue

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:

  1. As per __asm, generates program logic
  2. Generates program logic which generates a runtime object
  3. Embeds a resource into an assembly and generates program logic to load it and to parse it into a runtime object

Advantages

  1. Software quality
    1. Maintainability - suitability for debugging (localization and correction of errors) and for modification and extension of functionality
    2. Readability
    3. Testability - suitability for allowing the programmer to follow program execution (runtime behavior under given conditions) and for debugging
  2. Optimization with MSIL
  3. Complexity reduction in use of nested languages
    1. data languages (XML, RDF, CSV, etc) with IDE features
    2. querying languages (SQL, SPARQL, etc) with IDE features
    3. programming languages (Prolog, etc) with IDE features
    4. special purpose languages (SRGS, SSML, grammars) with IDE features

Examples

using language __msil = System.Runtime.MsilComponent;

class Example1
{
  void Function()
  {
    int x;

    __msil
    {
      ... x;
    }
  }
}
using language __xml = System.Xml.XmlComponent;

class Example2
{
  void Function()
  {
    System.Xml.XmlDocument x1 = __xml
    {
      <!-- -->
    }
    System.Xml.XmlDocumentFragment x2 = __xml
    {
      <!-- -->
    }
  }
}

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
dsafcommented, Sep 14, 2016

F#:

public void PrintColor(Color color)
{
    return
    __fs
    {
        match color with
        | Color.Red -> printfn "Red"
        | Color.Green -> printfn "Green"
        | Color.Blue -> printfn "Blue"
        | _ -> ()
    };
}
4reactions
alrzcommented, Sep 17, 2016

While we’re at it,

class HelloWorld
{
  static void Main()
  {
    __bf
    {
      ++++++++[>++++[>++>+++>+++>+<<<<-]>
      +>+>->>+[<]<-]>>.>---.+++++++..+++.
      >>.<-.<.+++.------.--------.>>+.>++.
    }
  }
}

+

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found