Replies: 3 comments 3 replies
-
As you may know, EC# has a fixed syntax that cannot be changed by a macro. However, that syntax includes something called "block-call expressions" which have the form Therefore you can simply call Please note that |
Beta Was this translation helpful? Give feedback.
-
Your version of the macro doesn't support nested loops, so I tried writing my own macro for this. My version has a loop counter named [Passive]
define (for#($item in $collection) { $(..block); })
{
int #unique# = 0;
foreach (var $item in $collection) {
replace (# => #unique#) {
$(..block);
}
++#unique#;
}
}
[PriorityFallback]
define (for#($collection) { $(..block); })
{
for# (it in $collection) {
$(..block);
}
}
for# (listA) {
Console.WriteLine("Now processing listA[" + # + "]");
for# (b in listB) {
c[#] += it * b;
}
}
The generated It looks okay, but LeMP reports an error that Something non-obvious here is the reason I wrote |
Beta Was this translation helpful? Give feedback.
-
@qwertie Cool I have expected the thing with the block as a last argument and happy that it is already implemented. |
Beta Was this translation helpful? Give feedback.
-
@qwertie
Imagine I want such a macro to expand into the
for
loop:and I want to call it like this:
The syntax is imaginary... I just want less noise.
Beta Was this translation helpful? Give feedback.
All reactions