Changes between Version 1 and Version 2 of Defaulting

Dec 5, 2005 11:43:33 PM (10 years ago)


  • Defaulting

    v1 v2  
    1212For replacement:
    1313 * Perhaps require a default clause to name the class being defaulted over, as well as the type to choose.
     15== proposal 1 ==
     17allow defaulting clauses of the following form
     20default <classname> (type1,type2,type3,...)
     23and the defaulting rule will take all class constraints and take the first unambiguous type that satisfies all the class constraints defaults.
     25classes without defaults will have the equivalant of an empty type list, so defaulting will not occur.
     27it is important to specify unambiguous because in the case of
     31default A (Int, String, ())
     32default B (String, Int, ())
     37the only valid default for a type in both classes should be () to avoid any issues arrising from order of interpretation of defaults.
     39=== pro ===
     41 * very useful in interactive interpreter
     42 * less ad hoc than current method.
     44=== con ===
     46 * can not exactly replicate behavior of existing defaulting mechanism, but can come close.
     47 * 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)