Skip to content Skip to sidebar Skip to footer

Access Parents Variable In Sweet.js

I'm creating a new object orientation system and I need to access the variables of the parent of the macro. I have the following: macro module { rule { $i:ident { $e ... } } =&

Solution 1:

There's a few ways to do this but I think the simplest thing to do is use named patterns:

macro module {
    rule { 
        $i:ident {
            $mbody:(fn $name:ident { $body ...}) ...
        }
    } => {
        $i.prototype.$mbody$name ...
    }
}

module x {
    fn name { 

    }
}

Post a Comment for "Access Parents Variable In Sweet.js"