vein-lang / vein

🔮⚡️Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support.
https://vein-lang.org
Other
52 stars 6 forks source link

Sync-method syntax support #19

Open 0xF6 opened 3 years ago

0xF6 commented 3 years ago

define sync in method declaration

public class Foo
{
   public sync fn(): void 
   { } 
}

Ishtar view (transformation result)


// non-static variant
public class Foo
{
   public fn(): void 
   { 
        Synchronicity.For(this);
        try
        {
            // ...
        }
        finally
        {
            Synchronicity.Release(this);
        }
   } 
}
// static variant
public static class Foo
{
   private static guarder: Object = new Object();
   public static fn(): void 
   { 
        Synchronicity.For(guarder);
        try
        { 
            // ...
        }
        finally
        {
            Synchronicity.Release(guarder);
        }
   } 
}