Override modifier that replaces a definition
In WebDSL the (built-in) templates can be overridden using the
override
modifier:template one(s:String){ output(s)"456" } override template one(s:String){ output(s)"123" } page root(){ one("0") }
This example results in showing
Submitted by Danny Groenewegen on 8 March 2013 at 16:210123
. It is not clear how to express this in NaBL, a workaround is to encode it in the resolution strategy that handles overloading. Additional constraints are that only one override is allowed and it must override something.
Issue Log
If it was just about the overriding, the solution would be simple:
StandardTemplate(...): defines Template t of override False() OverrideTemplate(...): defines Template t of override True() TemplateCall(...): refers to Template t of override True() otherwise refers to Template t of override False()
But the problem is, that this does not longer hold in the presence of overloading. Here, the overriding template should be chosen only, if it is a best match w.r.t. the parameters of the call. If a non-overridden template fits better, it wins.
With the new disambiguation clauses, we can pick the best match w.r.t. some
<subtype:
relation:StandardTemplate(t, p*): defines Template t of type (False(), fty*) where p* has type fry* OverrideTemplate(t, p*): defines Template t of type (False(), fty*) where p* has type fry* TemplateCall(t, a*): refers to Template t disambiguates Template t with t has type fty* and aty* <subtype: fty* by minimal fty* <subtype: where a* has type aty*
The relation needs to be defined in TS. Given a subtyping relation
<subtype:
for ordinary types, we can lift this to consider anoverride
property as well:(override1, fty1*) <subtype: (override2, fty2*) where fty1* <subtype: fty2* or ( fty1* == fty2* and override1 == True() and override2 == False() )
The first case describes the lifting. A composed type is a subtype of another composed type, when its parameter type list is a subtype of the other parameter type list, independent of the override part. The second case handles the overriding case, where both parameter lists are equivalent. In this case, the overriding part is taken into account.
Log in to post comments