velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nat...@esha.com>
Subject Re: macro & silent mode issue?
Date Thu, 22 Mar 2001 16:09:04 GMT
> Note well that Velocimacros are 'pass by name' by design, so to speak,
> to allow you to pass a reference with a method and have that method
> called for each instance of the arg in the macro body, not just the
> value. i.e.
[snip]
> This is done to allow stateful things, such as a method that returns a
> series of colors for coloring rows in a table, for example, to be used
> in VMs just like they would if they were used in the VTL.  This feature
> isn't an 'accident' or 'side effect' of implementation.

duly noted and understood.

> If you want the value to go in, do a
>
> #set($val = $ref.doIt() )
> #foo( $val )

hmmm. :(
ok, but i guess i still don't understand why

    #macro ( test $a)
        #if ($a)
            exists
        #end
    #end

    #test ($foo.getBar() )

isn't equivalent to

    #if ($foo.getBar()) exists #end

even if it is pass-by-reference, when it does get around to evaluating the
reference, shouldn't it evaluate the same?  it ought to remain a reference,
and not become a literal String representation of the reference. right?
basically, i've tried everything i can thing of to make this work w/o
having to do #set and then pass it.  Calling toString() is slightly
"better," but you end up with a lot of npe's in the log.  I'm stuck here,
and will stick with this hack for now but not happily.

Thanks for fixing the bug with String testing,  and i'll try to avoid being
a PITA about the VM arguments for a while. :)

Nathan Bubna


Mime
View raw message