Nemerle

What do you, guys, think about Nemerle programming language ?
Sorry about my bad english since I'm from Russia, actually, and for asking about foreign technology/language, but when I was watching the video about 'unless' statement and just thought how wonderful it would be to use the match+splicing+quasiquotation construct instead of the if/else's and checking the type of AST node explicitly in code for replacing an 'unless' statement with an 'if' statement. It would be awesome to have expressiveness of this code fragment in MPS:



macro ForIndex (expr, step, body)
syntax ("forindex", "(", expr, Optional ("step", step), ")", body)
{
  def step = if (step == null) <[ 1 ]> else step;
  
  match (expr)
  {
    | <[ $minExpr <= $i <= $maxExpr ]> =>
      <[ for (mutable $i = $minExpr; $i <= $maxExpr; $i += $step)
           $body ]>

    | <[ $minExpr <  $i <= $maxExpr ]> =>
      <[ for (mutable $i = $minExpr + 1; $i <= $maxExpr; $i += $step)
           $body ]>

    | <[ $minExpr <  $i < $maxExpr ]> =>
      <[ for (mutable $i = $minExpr + 1; $i <  $maxExpr; $i += $step)
           $body ]>

    | <[ $minExpr <= $i <  $maxExpr ]> =>
      <[ for (mutable $i = $minExpr;     $i <  $maxExpr; $i += $step)
           $body ]>

    | _ => Message.Error(expr.Location, $"Syntax error '$expr'");
           <[ () ]>
   
  }
}
2 comments
BTW, this code fragment trys to add the following syntactic constructs, by example:

forindex (0 < i < 10)
  WriteLine("Hello, World !");

forindex (0 < i <= 10)
  WriteLine("Hello, World !");

forindex (0 <= i < 10)
  WriteLine("Hello, World !");

forindex (0 <= i <= 10)
  WriteLine("Hello, World !");




There is an optional 'step' :

forindex (0 <= i <= 10 step 2)
  WriteLine("Hello, World !");

Also, it worth noting that in base Nemerle language mutable variable i is declared with 'mutable' prefix specifier.
0
Sorry, guys, I've forgotten to ask whether everything else is clear with that code sample ?
0

Please sign in to leave a comment.