In WebDSL the (built-in) templates can be overridden using the override modifier:

template one(s:String){

template one(s:String){

page root(){

This example results in showing 0123. 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.

Submitted by Danny Groenewegen on 8 March 2013 at 16:21

On 8 March 2013 at 18:36 Guido Wachsmuth tagged rfc

On 8 March 2013 at 18:43 Guido Wachsmuth commented:

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.

On 20 May 2014 at 22:36 Guido Wachsmuth commented:

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 an override 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