Don Brown wrote:

On Sun, 27 Feb 2005 14:16:23 +0100, Sylvain Wallez <[EMAIL PROTECTED]> wrote:
<snip />


This is actually similar to ServletRequest.getParameterMap() in servlet
2.4 which we do not have on our Request interface. But we should not
introduce special wrappers for Map as proposed recently by the
Struts-flow guy (need to make an answer and point him to this
discussion) as we would just be moving the problem one level deeper:
what would "map.size" mean if it contains a "size" entry?



As I see it, there are two ways to solve this problem:

1. Use ordering ie function, property so function calls are used first
(or vice versa)
2. Use a special function prefix to ensure functions are called. In
my implementation, I have an optional "fn_" which can be used to
ensure you are calling a function and it cannot be overridden. Any
prefix should, of course, be able to be turned off or changed.



The simple fact that we have to elaborate such strategies IMO reveals that there's a problem. This problem comes from the fact that a dynamic property space (request parameters, map entries, etc) is merged with a static property space (coming from the Java object), and that's why I proposed an additional static property to hold the dynamic space.


In the case of request, this leads to both "request.parameters" and "request.attributes" as we have two dynamic property spaces.

In the case of Map, this could be "map.entries", i.e. you would write "map.entries.foo" instead of map.get("foo"). But we can also consider that Map is of a special kind as it is nothing but a dynamic property space for Java. In that very particular case, we could reverse the scheme and have the dynamic space be the main property space (i.e. "map.foo") and have the actual Map methods be accessed through a single special property, e.g. "map.__obj__.size()". Mmmh...

That said, this is not an issue for the wrapper around List.


Yes, because a List's dynamic property space is defined by numbers (the index), and there is therefore no overlapping between the regular object's properties and the ones added by the special wrapper.


I wrote
a framework so you can add properties and methods to Java API's in a
generic way, and I use this to, among other things, add a "length"
property to any object that implements Collection to make it more
consistant with what one would expect to use with a JS array. My
favorite use of extension functions is to add closure functions such
as File.eachLine(func).



That's groovy, in all meanings of it ;-)

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



Reply via email to