Interop¶
Interop is one of the main reasons Makrell# exists.
This section should eventually cover:
importing namespaces and types
CLR construction and member access
generic type usage
generic method calls
delegates and function adaptation
dynamic loading and compiled assemblies
Representative imports¶
{import System.Text}
{import System.Text@[Encoding]}
{import System.Text.StringBuilder}
{import (list string)}
Makrell-shaped generic types¶
{new (list string) ["a" "b"]}
{new (dict string int) [["a" 1] ["b" 2]]}
{new (array string) ["a" "b"]}
Static and instance examples¶
{import System.Text}
sb = {new StringBuilder ["Mak"]}
{sb.Append "rell#"}
{sb.ToString}
Generic method examples¶
Explicit generic calls are supported:
{import System.Linq}
repeated = {Enumerable.Repeat@(string) "ha" 3}
{String.Join "" repeated}
Makrell# also handles some common inferred generic static calls, which makes interop feel closer to ordinary CLR use:
{import System.Linq}
repeated = {Enumerable.Repeat "ha" 3}
{String.Join "" repeated}
{import System.Threading.Tasks@[Task]}
task = {Task.FromResult 42}
{await task}
What this page is about¶
Makrell# interop is about making CLR access fit naturally into Makrell-shaped code.
In practice, that means:
imports should look like part of the language, not bolted-on foreign syntax
generic types should use Makrell-shaped forms
object construction, member access, and static calls should compose with normal Makrell flow
common generic calls should not feel artificially noisy when CLR type inference already has enough information
Representative combined example¶
{import System.Text}
names = {new (list string) ["Makrell" "Sharp"]}
joined = {String.Join " " names}
sb = {new StringBuilder []}
{sb.Append joined}
{sb.ToString}