[nem-bug] [Nemerle 0001014]: InheritConstructors macro
feedback at nemerle.org
feedback at nemerle.org
Sun May 13 15:47:50 CEST 2007
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=1014>
======================================================================
Reported By: VladD2
Assigned To: nazgul
======================================================================
Project: Nemerle
Issue ID: 1014
Category: The Macro Library
Reproducibility: always
Severity: feature
Priority: normal
Status: feedback
======================================================================
Date Submitted: 05-12-2007 17:23 CEST
Last Modified: 05-13-2007 15:47 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? :)
----------------------------------------------------------------------
nazgul - 05-12-07 19:18
----------------------------------------------------------------------
Yes, I think this would be very useful - I think that Record and
InheritConstructors macros could use exactly the same implementation -
Inherit would be just simpler, since it does not consider any fields.
----------------------------------------------------------------------
VladD2 - 05-12-07 23:29
----------------------------------------------------------------------
You can do this? :)
----------------------------------------------------------------------
nazgul - 05-13-07 11:50
----------------------------------------------------------------------
Fixed on trunk (r7675)
----------------------------------------------------------------------
VladD2 - 05-13-07 15:44
----------------------------------------------------------------------
InheritConstructors don't work with AbstractFactory mcro.
Kamil, try test the InheritConstructors on the class IntelliSenseModeTyper
from VS Integration.
http://nemerle.org/svn/vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeTyper.n
It lead to error:
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-13-07 15:47
----------------------------------------------------------------------
Yes, this is the problem of AbstractFactory macro and cannot be done
easily. This can be fixed only after implementing macro dependencies
(http://nemerle.org/bugs/view.php?id=199)
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
05-12-07 19:18 nazgul Note Added: 0001884
05-12-07 23:29 VladD2 Note Added: 0001885
05-13-07 11:50 nazgul Status new => resolved
05-13-07 11:50 nazgul Resolution open => fixed
05-13-07 11:50 nazgul Assigned To => nazgul
05-13-07 11:50 nazgul Note Added: 0001886
05-13-07 11:50 nazgul Description Updated
05-13-07 15:44 VladD2 Status resolved => feedback
05-13-07 15:44 VladD2 Resolution fixed => reopened
05-13-07 15:44 VladD2 Note Added: 0001888
05-13-07 15:44 VladD2 Description Updated
05-13-07 15:47 nazgul Note Added: 0001889
======================================================================
More information about the bugs
mailing list