From: Eric B. R. <eb...@tc...> - 2003-07-23 18:33:55
|
On Wednesday, July 23, 2003, at 02:30 PM, Keats wrote: > I like having it be a Map. For example, #eval needs a Map for the > "using" > clause. Can't we just implement a map that overrides put to allways > return > an empty String? we can. or we can add a public void set(Object key, Object value) method. #set $map = {} $map.set("Foo", "Bar") $map.set("Tree", "Flower") it kinda fits along with: #set $map.Foo = "Bar" #set $map.Tree = "Flower" but is useful in the cases where your keyname is $dynamic eric > > Keats > ----- Original Message ----- > From: "Eric B. Ridge" <eb...@tc...> > To: <ma...@an...> > Cc: <web...@li...> > Sent: Wednesday, July 23, 2003 1:55 PM > Subject: Re: [Webmacro-devel] Here's why I don't like the Map > constructor > stuff > > >> On Wednesday, July 23, 2003, at 01:47 PM, Marc Palmer wrote: >> >>> >>> Hi, >>> >>> I thought I'd try using the #set $xxx = { } mechanism today. >>> >>> If you remember there was a real hoo-haa about this versus my >>> #newobject directive (which is fine and working well in Ignition I >>> might add!). >>> >>> Now I tried this: >>> >>> #set $x = {} >>> #foreach $item in $myNameList >>> $x.put( $item, $values.get($item) ) >>> #end >>> >>> ...and guess what? I get all the values in the output because put() >>> returns an Object! >> >> So we make {} return a special object too. It doesn't necessarily >> need >> to be a java.util.Map implementation. >> >> eric >> >>> >>> This is really bad news. #newobject does not suffer this because I >>> return a custom object not a Hashtable/Map that is de-Java-lized: >>> >>> public class WebMacroObject >>> { >>> public int getCount() >>> public Iterator getPropertyNames() >>> public Iterator getPropertyValues() >>> public void put( String key, Object value ) >>> public Object get( String key ) >>> public void reset() >>> public void copyFrom( WebMacroObject src ) >>> public void copyFrom( Map src ) >>> } >>> >>> This is much cleaner and does not suffer from the Map contract >>> problems. This object can of course be used without #newobject, it is >>> completely standalone. Java heads may shriek at the altered syntax, >>> but I think it stands well in the non-Java world. >>> >>> Shall I commit this object to CVS and edit the { } map constructor >>> mechanism to create an instance of this instead of the Map >>> implementation it does now? >>> >>> ...or is there another solution? >>> >>> I feel that, like my suggestion for a list wrapper object, we should >>> consider providing some special WM types for this kind of stuff to >>> de-Java- lize things further and start building a small "WebMacro >>> Object Model" in this regard, so we can document it clearly for >>> template writers instead of referring them to API Javadocs for Map, >>> for example. >>> >>> Just say the word and WebMacroObject is in CVS and { } updated to use >>> it... and if you really feel friendly you could let me add #newobject >>> to WM to back up the "WebMacro Object Model" :) >>> >>> Marc >>> -- >>> Marc Palmer >>> Contract Java Consultant/Developer >>> >>> w a n g j a m m e r s >>> >>> java and web software design >>> experts with an ethical outlook >>> >>> http://www.wangjammers.org >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email sponsored by: Free pre-built ASP.NET sites >>> including >>> Data Reports, E-commerce, Portals, and Forums are available now. >>> Download today and enter to win an XBOX or Visual Studio .NET. >>> http://aspnet.click-url.com/go/psa00100003ave/ >>> direct;at.aspnet_072303_01/01 >>> _______________________________________________ >>> Webmacro-devel mailing list >>> Web...@li... >>> https://lists.sourceforge.net/lists/listinfo/webmacro-devel >> >> >> >> ------------------------------------------------------- >> This SF.Net email sponsored by: Free pre-built ASP.NET sites including >> Data Reports, E-commerce, Portals, and Forums are available now. >> Download today and enter to win an XBOX or Visual Studio .NET. >> > http://aspnet.click-url.com/go/psa00100003ave/ > direct;at.aspnet_072303_01/01 >> _______________________________________________ >> Webmacro-devel mailing list >> Web...@li... >> https://lists.sourceforge.net/lists/listinfo/webmacro-devel > |