Changes between Version 2 and Version 3 of Defaulting


Ignore:
Timestamp:
Dec 6, 2005 5:43:15 PM (8 years ago)
Author:
malcolm.wallace@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Defaulting

    v2 v3  
    1313 * Perhaps require a default clause to name the class being defaulted over, as well as the type to choose. 
    1414 
     15Other issues: 
     16 * A default clause applies only within the module containing the declaration.  Defaults can be neither 
     17   exported nor imported.  Does anyone wish to propose import/export of defaults? 
     18   * For import/export: easier to propagate user-defined class defaults throughout a project 
     19   * Against import/export: a change in the imports of a module might silently change behavior 
     20 
    1521== proposal 1 == 
    1622 
    17 allow defaulting clauses of the following form 
     23Allow defaulting clauses of the following form 
    1824 
    1925{{{ 
     
    2127}}} 
    2228 
    23 and the defaulting rule will take all class constraints and take the first unambiguous type that satisfies all the class constraints defaults. 
     29The defaulting rule will simply choose the first unambiguous type that satisfies all the constrained classes 
     30listed in the default decls. 
    2431 
    25 classes without defaults will have the equivalant of an empty type list, so defaulting will not occur. 
     32Classes without defaults will have the equivalent of an empty list of types, so defaulting will not occur. 
    2633 
    27 it is important to specify unambiguous because in the case of 
     34It is important to specify "unambiguous", because in the case of 
    2835 
    2936{{{ 
    30  
    3137default A (Int, String, ()) 
    3238default B (String, Int, ()) 
    33  
    34  
    3539}}} 
    3640 
    37 the only valid default for a type in both classes should be () to avoid any issues arrising from order of interpretation of defaults. 
     41the only valid default for a type in both classes A and B should be ().  This avoids making an arbitrary choice based on 
     42textual ordering of the default declaration clauses. 
    3843 
    3944=== pro === 
    4045 
    4146 * very useful in interactive interpreter 
    42  * less ad hoc than current method. 
     47 * less ad hoc than current method 
     48 * overcomes the Hat transformation problem 
    4349 
    4450=== con === 
     
    4652 * can not exactly replicate behavior of existing defaulting mechanism, but can come close. 
    4753 * might hide errors, an optional warning on defaulting should be possible. 
    48  * importing a module might silently change behavior (this can be mitigated if we only allow default definitons in the same module as the class is defined, but that takes away the ability to redefine defaults)