Using operator macros in C#

96 views
Skip to first unread message

syjell

unread,
Apr 18, 2017, 6:43:49 AM4/18/17
to Nemerle Forum
In article Macros---extended-course.-Part-1 I saw the following:

"Operator macros allow one to introduce new operators into the language. ... Additionally, such operators would be accessible from C# (if the type in which they are defined is public)."

I'm already using Nemerle attribute macros in C#, which works great.

But I haven't managed to get an operator macro working in C#. Could someone provide a basic example?

Thanks!

NN

unread,
May 1, 2017, 12:50:20 PM5/1/17
to Nemerle Forum
You can compile C# using Nemerle compiler. It is one option.

syjell

unread,
May 2, 2017, 5:33:39 AM5/2/17
to Nemerle Forum
That's exactly what I am doing. I compile C# using Nemerle compiler.
While doing this I can even use Nemerle attribute macros in C#. Additionally I also wanted to use Nemerle operator macros in C#. But the Nemerle compiler gives me an error: "Expected: statement".
Let's consider a very basic example, using the Nemerle swap operator "<->"

using Nemerle;
using System;
namespace ConsoleApplication1
{
 
class SomeClass
 
{
       
static void Main()
       
{
           
int a = 1;
           
int b = 5;
            a
<-> b;
       
}
   
}
}

Compilation with ncc.exe results in:

SomeClass.cs(11,13): error : Expected: statement


What am I doing wrong? Could someone point me to the right direction?
Thanks!


NN

unread,
May 2, 2017, 6:13:21 AM5/2/17
to Nemerle Forum
Sorry you cannot do it.
Only macro attributes are supported.
C# is not designed as extendable language.
Reply all
Reply to author
Forward
0 new messages