![]() |
Quick MERL concatenating in MetaEdit+ 5.0 |
Post Reply
|
| Author | |
stevek
MetaCase
Joined: 11.Mar.2008 Points: 643 |
Post Options
Thanks(0)
Quote Reply
Topic: Quick MERL concatenating in MetaEdit+ 5.0Posted: 13.Sep.2012 at 14:52 |
|
In MERL we can assign variables:
but we can't assign multiple strings in a single assignment:
That gets parsed as an assignment $c ='foo', plus an output of $a. In 4.5 for an assignment and a concatenation, you used the full variable command:
In 5.0 we can use subgenerators as functions, with parentheses surrounding the comma-separated arguments. Each argument can be formed by the output of multiple commands: just like in Java you can write "foo(name+" "+surname, b)", in MERL you can write "foo($name ' ' $surname, $b)". MERL concatenates the output from all of an argument's commands, then passes the result as the argument. So if we define a MERL generator function that simply outputs its single argument:
we can use it to concatenate multiple commands. This lets us rewrite our initial example as:
Or even better, if we rename concat() to __():
which will be ignored because of its __ prefix when building the generator call tree hierarchy display, and so become almost part of the language. And now in all the places where before you could only have a single command (assignment RHS, comparison LHS and RHS...), you can have a concatenation almost for free.
|
|
![]() |
|
Post Reply
|
|
| Tweet |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |