[nem-en] macros attached to methods
Michal Moskal
michal.moskal at gmail.com
Thu May 4 13:47:59 CEST 2006
Hi,
we have an issue report about implementing macros attached to
particular methods. They should be run, when a given method is
selected in overload resolution. The original rationale was to allow
implementing extension methods with this. However we now have
extension methods anyway.
I'm not sure how such feature would work and when would it be useful?
One use I can think of is implementing .Keys or .Range property in
array (and possibly other types), that could be used in foreach
iterations, it would return $[0 .. a.Length - 1]. So the use would be:
foreach (i in a.Keys)
a[i] = a[i] * 2;
Unfortunately this won't gonna fly -- the macro would be expanded too
late for @foreach macro to realize the collection iterated is a range,
and therefore a specialized code should be used. Maybe if we could use
some more complicated constraints to delay parts of macro execution,
but this doesn't seem simple.
Anyway it seems worthwhile to implement such a keys or range macro in
N.Collections.
Any other ideas when macros attached to methods would be useful? Anyone?
--
Michał
More information about the devel-en
mailing list