[nem-bug] [Nemerle 0001014]: InheritConstructors macro

feedback at nemerle.org feedback at nemerle.org
Sat May 12 18:09:27 CEST 2007


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=1014> 
======================================================================
Reported By:                VladD2
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   1014
Category:                   The Macro Library
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             05-12-2007 17:23 CEST
Last Modified:              05-12-2007 18:09 CEST
======================================================================
Summary:                    InheritConstructors macro
Description: 
If you inherit one class from another, some time, you should copy all it
constructors. Will be nice create macro which do it automatically.
For example. Instead of:
public class IntelliSenseModeTyper : Typer
{
  public this (m : MethodBuilder) { base (m) }
  public this (parent : Typer, fn : Typedtree.Fun_header) { base (parent,
fn) }
  public this (
    tb : TypeBuilder, 
    tenv : TyVarEnv,
    fn : Typedtree.Fun_header,
    env : GlobalEnv)
  {
    base (tb, tenv, fn, env)
  }
    
  protected override RunDelayedTypings () : void { ... }
  protected override RunSecondPass (_meth : MethodBuilder) : void { ... }
}

we could write:
[InheritConstructors]
public class IntelliSenseModeTyper : Typer
{
  protected override RunDelayedTypings () : void { ... }
  protected override RunSecondPass (_meth : MethodBuilder) : void { ... }
}

This macro should be not copy ctor if in new class already defined ctor
with same signature.
======================================================================

----------------------------------------------------------------------
 nazgul - 05-12-07 18:09 
----------------------------------------------------------------------
You can use [Record] macro for this purpose. In classes with some fields it
requires additonal work to choose which fields should be also included, but
to have just your specification you could do:

[Record (Include = [])]
class A : B { 
  priv_field : int;
}

Issue History
Date Modified  Username       Field                    Change              
======================================================================
05-12-07 17:23 VladD2         New Issue                                    
05-12-07 18:09 nazgul         Note Added: 0001879                          
======================================================================




More information about the bugs mailing list