[ http://issues.apache.org/jira/browse/VELOCITY-365?page=all ]

Will Glass-Husain updated VELOCITY-365:
---------------------------------------

    Bugzilla Id:   (was: 33833)
    Description: 
ok, the motive of this feature request is that we shouldn't have to distinguish
between an $array and a $list when writing templates.  this is already handled
to a degree in the #foreach() directive which transparently handles both arrays
and Lists (among other things), and it seems logically consistent with the way
VTL already hides the difference between primitives and their wrappers (int vs.
Integer).

so, in this same spirit, i propose that we should enable template authors to
access items by index, determine the size of, and manipulate (to a point) Lists
and arrays identically.  here's an example that demonstrates how i think this
should work:

Access Item at Index 2:
$list.get(2) ##works already
$array.get(2) ##doesn't work right now

Determine size:
$list.size() ##works already
$array.size() ##wish this would work

you get the idea, right?  basically, i would like to have all operations that
make sense for an array supported (which i believe means most List methods
except the add(), remove(), and clear() ones).

IMHO, this would simplify things for users noticeably and eliminate the need for
such things as an ArrayTool in the VelocityTools library.

at this point, i'm not sure what the best approach for implementing this is.  it
may simply be the automatic, transparent wrapping of arrays inserted into the
context with some sort of ArrayList wrapper class.  or i suppose it could
involve some crazy Uberspect trickery.

now all we need is someone with the time to whip up a patch...

  was:
ok, the motive of this feature request is that we shouldn't have to distinguish
between an $array and a $list when writing templates.  this is already handled
to a degree in the #foreach() directive which transparently handles both arrays
and Lists (among other things), and it seems logically consistent with the way
VTL already hides the difference between primitives and their wrappers (int vs.
Integer).

so, in this same spirit, i propose that we should enable template authors to
access items by index, determine the size of, and manipulate (to a point) Lists
and arrays identically.  here's an example that demonstrates how i think this
should work:

Access Item at Index 2:
$list.get(2) ##works already
$array.get(2) ##doesn't work right now

Determine size:
$list.size() ##works already
$array.size() ##wish this would work

you get the idea, right?  basically, i would like to have all operations that
make sense for an array supported (which i believe means most List methods
except the add(), remove(), and clear() ones).

IMHO, this would simplify things for users noticeably and eliminate the need for
such things as an ArrayTool in the VelocityTools library.

at this point, i'm not sure what the best approach for implementing this is.  it
may simply be the automatic, transparent wrapping of arrays inserted into the
context with some sort of ArrayList wrapper class.  or i suppose it could
involve some crazy Uberspect trickery.

now all we need is someone with the time to whip up a patch...

        Version: 1.6
                     (was: 1.5)
    Environment: 
Operating System: All
Platform: All

  was:
Operating System: All
Platform: All

      Assign To:     (was: Velocity-Dev List)

I like the idea of just wrapping arrays in ArrayList somehow, probably in the 
Uberspector.  I've set this as a 1.6 feature.

WILL

> handle Lists & arrays similarly
> -------------------------------
>
>          Key: VELOCITY-365
>          URL: http://issues.apache.org/jira/browse/VELOCITY-365
>      Project: Velocity
>         Type: Improvement
>   Components: Source
>     Versions: 1.6
>  Environment: Operating System: All
> Platform: All
>     Reporter: Nathan Bubna
>     Priority: Minor

>
> ok, the motive of this feature request is that we shouldn't have to 
> distinguish
> between an $array and a $list when writing templates.  this is already handled
> to a degree in the #foreach() directive which transparently handles both 
> arrays
> and Lists (among other things), and it seems logically consistent with the way
> VTL already hides the difference between primitives and their wrappers (int 
> vs.
> Integer).
> so, in this same spirit, i propose that we should enable template authors to
> access items by index, determine the size of, and manipulate (to a point) 
> Lists
> and arrays identically.  here's an example that demonstrates how i think this
> should work:
> Access Item at Index 2:
> $list.get(2) ##works already
> $array.get(2) ##doesn't work right now
> Determine size:
> $list.size() ##works already
> $array.size() ##wish this would work
> you get the idea, right?  basically, i would like to have all operations that
> make sense for an array supported (which i believe means most List methods
> except the add(), remove(), and clear() ones).
> IMHO, this would simplify things for users noticeably and eliminate the need 
> for
> such things as an ArrayTool in the VelocityTools library.
> at this point, i'm not sure what the best approach for implementing this is.  
> it
> may simply be the automatic, transparent wrapping of arrays inserted into the
> context with some sort of ArrayList wrapper class.  or i suppose it could
> involve some crazy Uberspect trickery.
> now all we need is someone with the time to whip up a patch...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to