moniel icon indicating copy to clipboard operation
moniel copied to clipboard

Get rid of Scopes

Open mlajtos opened this issue 9 years ago • 3 comments

Scopes are nothing more than anonymous metanodes, so having a special notation for them is unnecessary.

~~Scope notation~~ (old syntax):

/scope{ In -> Id -> Out}
In -> scope -> Out

Metanode notation:

scope:{ In -> Id -> Out}
In -> scope -> Out

Inline Metanode notation:

In -> scope:{ In -> Id -> Out} -> Out

Anonymous Inline Metanode notation:

In -> { In -> Id -> Out} -> Out

This notation can replace Block Definitions (old name) with Metanode Definitions. So this:

+DoubleIdentity{ In -> Id -> Id -> Out }
In -> DoubleIdentity -> Out

Becomes this:

DoubleIdentity:{ In -> Id -> Id -> Out}
In -> DoubleIdentity -> Out

Therefore one could create metanodes just by copying existing ones, but with different parameters:

DoubleNegation:{
    MyInvert:Invert(mask = 0x0x1)
    In -> MyInv -> MyInv -> Out
}

But the biggest adavantage is ability to lift concrete instance to a class (think siamese architecture):

concreteModel:Model
SharedModel:concreteModel
In -> [SM,SM] -> Out

mlajtos avatar Oct 03 '16 22:10 mlajtos

In standalone parser definitions look like this:

+Node:{ In -> Out }
+(Node2 -param defaultValue):{ In -> Out }

Also there is a full support for anonymous metanodes.

Aliasing is not possible yet, but can be substituted with composition:

// Nope: MyDropout:(Dropout -p 0.618)
+MyDropout:{ In -> (Dropout -p 0.618) -> Out }

(I kept the + sign since it is a good indicator of a new definition.) I have no idea how lifting should work.

mlajtos avatar Jun 23 '17 11:06 mlajtos

Anonymous metanodes are also supported in Moniel – 3c4f38b5cbb633469850473d53f5fcf6c8aacd80

(This code is total mess, but it is better to go with it and clean it rather to start a new mess.)

Also, composition without In/Out nodes will be much cleaner:

+MyDropout{ Dropout(prob=0.618) }

(Btw params are first-class subnodes, so colon notation should be also usable there.)

mlajtos avatar Nov 02 '17 23:11 mlajtos

But "scope" concept is still in code, so getting rid of it would be nice...

mlajtos avatar Nov 02 '17 23:11 mlajtos