[nem-bug] [Nemerle 0001019]: Feature request: Extension macros

feedback at nemerle.org feedback at nemerle.org
Tue May 22 22:17:23 CEST 2007


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=1019> 
======================================================================
Reported By:                VladD2
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   1019
Category:                   Compiler (parser/macros engine)
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             05-20-2007 19:47 CEST
Last Modified:              05-22-2007 22:17 CEST
======================================================================
Summary:                    Feature request: Extension macros
Description: 
For many tasks will be useful Extension macros. For example Extension
macros will be useful for implementing DLinq (Linq to SQL) functionality.

I think syntax of Extension macro should be:
macro MacroName[T](this : Info[TypeForExtending[T]][..., argExprN])
{
  ...
}
where [..., argExprN] is a any numbers of parametr
or:
macro MacroName[T](this : Info[TypeForExtending[T]], params paramArray :
array[PExpr])
{
  ...
}
or:
macro MacroName[T](this : Info[TypeForExtending[T]], params paramArray :
list[PExpr])
{
  ...
}



Example:
macro Where[T](this : Info[IQueryable[T]], lamdaExpr)
{
  def linqExpr = ToLinqExpression(lamdaExpr);
  <[ System.Linq.Queryable.Where($(this.PExpr), $linqExpr) ]>
}

Info give information about type of "this" parametr and in PExpr/TExpr
representation.

using:
SomeMethod(queryable : IQueryable[Customer])
{
  queryable.Where(c => c.Name.StartsWith("J"))
}

I think Extension macros is possible implement under Extension methods. We
can create one Extension method for each Extension macro and replace method
call to macro call when type of first parametr be known.
======================================================================

----------------------------------------------------------------------
 malekith - 05-21-07 22:21 
----------------------------------------------------------------------
Somewhat problematic is, that we type all the parameters before deciding
the extension method, so we would somehow need to undo this (which can be
problematic, if for example some of the parameters contain type errors).

----------------------------------------------------------------------
 VladD2 - 05-22-07 22:17 
----------------------------------------------------------------------
In fact all macros are a "generic".
We can interpret Extension macro as method which has one typed parameter
and some number of parameters which typed as object.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
05-20-07 19:47 VladD2         New Issue                                    
05-21-07 22:21 malekith       Note Added: 0001905                          
05-22-07 22:17 VladD2         Note Added: 0001906                          
======================================================================




More information about the bugs mailing list