MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Quick MERL concatenating in MetaEdit+ 5.0
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Quick MERL concatenating in MetaEdit+ 5.0

 Post Reply Post Reply
Author
Message
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Topic: Quick MERL concatenating in MetaEdit+ 5.0
    Posted: 13.Sep.2012 at 14:52
In MERL we can assign variables:
$a = 'foo'
$b = $a
but we can't assign multiple strings in a single assignment:
$c = 'foo' $a
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:
variable 'c' write
   'foo'
   $a
close
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:
concat(@arg)
   @arg
we can use it to concatenate multiple commands. This lets us rewrite our initial example as:
$c = concat('foo' $a) /* NB only one argument, not concat ('foo', $a) */
Or even better, if we rename concat() to __():
$c = __('foo' $a)
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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.023 seconds.