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

feedback at nemerle.org feedback at nemerle.org
Sat May 12 19:09:21 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 19: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;
}

----------------------------------------------------------------------
 VladD2 - 05-12-07 18:20 
----------------------------------------------------------------------
It's not intuitive :(.
Maybe move this functionality into separate macro?



----------------------------------------------------------------------
 VladD2 - 05-12-07 18:24 
----------------------------------------------------------------------
Hm...
I tring iit on IntelliSenseModeTyper:
  [Record (Include = [])]
  public class IntelliSenseModeTyper : Typer
  {
    /*public this (m : MethodBuilder) { base (m) }
    public this (tb : TypeBuilder, tenv : TyVarEnv, mb : MethodBuilder,
env : GlobalEnv)
    { base(tb, tenv, mb, env) }
    public this (parent : Typer, fn : TT.Fun_header) { base(parent, fn) }
    */

and take this error message:
Factories.n(8,4,8,59): error : `override' specified on method
Nemerle.Completion2.Factories.IntelliSenseModeCompilerComponentsFactory.CreateTyper()
: Nemerle.Compiler.Typer, 
but there is no method with this signature in parent to override

----------------------------------------------------------------------
 nazgul - 05-12-07 18:31 
----------------------------------------------------------------------
Oh, now I remember why those constructors are written by hand - the Factory
macro does not see those creted by Record.

----------------------------------------------------------------------
 VladD2 - 05-12-07 19:09 
----------------------------------------------------------------------
And what about my proposal? :)

Issue History
Date Modified  Username       Field                    Change              
======================================================================
05-12-07 17:23 VladD2         New Issue                                    
05-12-07 18:09 nazgul         Note Added: 0001879                          
05-12-07 18:19 VladD2         Note Added: 0001880                          
05-12-07 18:20 VladD2         Note Edited: 0001880                         
05-12-07 18:24 VladD2         Note Added: 0001881                          
05-12-07 18:31 nazgul         Note Added: 0001882                          
05-12-07 19:09 VladD2         Note Added: 0001883                          
======================================================================




More information about the bugs mailing list