[Ferm] adding to a list

Marc Haber mh+ferm at zugschlus.de
Fri Mar 4 10:41:21 CET 2011


Hi,

On Fri, Mar 04, 2011 at 09:26:43AM +0100, Max Kellermann wrote:
> You cannot modify a "parent stack frame" variable with the first
> variant.  This could maybe be implemented with something such as:
> 
>  @def @parent_stackframe($l) = ....
> 
> (Ugly name, just to demonstrate the point) .. which would tell ferm to
> refer to another stack frame.  Not an elegant solution.

... but frequently seen in other programming languages with statements
like "global foo", telling the compiler/interpreter not to overload
the global foo with a local instance of foo.

> Second variant: we could add passing parameter "by reference",
> outline:
> 
>  @def &add_to_list(@by_ref($list), $item) = {
>    @def $list = ($list $item);
>  }
> 
> "@byref" would tell ferm to substitute $list references by the actual
> variable passed here, not by its value.  That seems like the more
> elegant solution to me.

Indeed. That's, however, well beyond my ferm-foo at the moment. I
could, however, do some testing, supply the docs and test cases.

Greetings
Marc

-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany  |  lose things."    Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature |  How to make an American Quilt | Fax: *49 3221 2323190


More information about the Ferm mailing list