Yes.
import macros
macro cfor(stm,bdy:untyped):untyped =
echo "semicolon:"
echo " stm: ",stm.lisprepr
echo " bdy: ",bdy.lisprepr
macro cfor(stms:varargs[untyped]):untyped =
echo "varargs:"
for c in stms:
echo " ",c.lisprepr
cfor (i=0;i<4;++i): # the space between cfor and ( is important
echo i
cfor(i=0,i<4,++i):
echo i
A stricter 4 formal parameter macro is possible but you can't use = and ;.
import macros
macro cfor(stm,bdy:untyped):untyped =
echo "semicolon (requires space after `cfor`):"
echo " stm: ",stm.lisprepr
echo " bdy: ",bdy.lisprepr
macro cfor(ini,tst,upd,bdy:untyped):untyped =
echo "comma without `=`"
echo " ini: ",ini.lisprepr
echo " tst: ",tst.lisprepr
echo " upd: ",upd.lisprepr
echo " bdy: ",bdy.lisprepr
macro cfor(stms:varargs[untyped]):untyped =
echo "varargs catches `=`:"
for c in stms:
echo " ",c.lisprepr
cfor (i=0;i<4;++i): # the space between cfor and ( is important
echo i
cfor(i:=0,i<4,++i):
echo i
cfor(i=0,i<4,++i): # Nim parses `i` as a named parameter
echo i