You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Jose Alberto Fernandez <JF...@viquity.com> on 2000/12/21 20:30:23 UTC

RE: cvs commit: jakarta-velocity/src/java/org/apache/velocity Con text.java

> From: Daniel Rall [mailto:dlr@finemaltcoding.com]
> 
> 
> "Geir Magnusson Jr." <gm...@xyris.com> writes:
> 
> > I personally think that Context should accept null values 
> and keys and not
> > throw exceptions, but that's just me.  If you want to store 
> a null, great.
> > Context will give it back when you ask for it :)
> > 
> > It's not a Hashtable.  It uses a Hashtable.  It acts like a 
> hashtable.  But
> > it's not a hashtable.
> 
> Null values are your friend.  I'm not sure of the value of 
> null keys, however.
> 

I would agree with you that it would make sense to differentiate 
between A variable in the Context that happens to be NULL and
an trying to access an undeclared variable. The former is a perfectly
valid situation, the later looks like a template misused to me.

Notice that the fact that we cannot store null values in the Context
is due to the fact that we use a java.util.Hashtable in its implementation.
If we used instead a java.util.HashMap we could store NULL values.
Moreover, HashMap access is not syncronized, which given our usage
of Context is unnecessary. That could even speed things up.

Jose Alberto

Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity Context.java

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jose Alberto Fernandez wrote:
> 
> > From: Daniel Rall [mailto:dlr@finemaltcoding.com]
> >
> >
> > "Geir Magnusson Jr." <gm...@xyris.com> writes:
> >
> > > I personally think that Context should accept null values
> > and keys and not
> > > throw exceptions, but that's just me.  If you want to store
> > a null, great.
> > > Context will give it back when you ask for it :)
> > >
> > > It's not a Hashtable.  It uses a Hashtable.  It acts like a
> > hashtable.  But
> > > it's not a hashtable.
> >
> > Null values are your friend.  I'm not sure of the value of
> > null keys, however.
> >
> 
> I would agree with you that it would make sense to differentiate
> between A variable in the Context that happens to be NULL and
> an trying to access an undeclared variable. The former is a perfectly
> valid situation, the later looks like a template misused to me.
> 
> Notice that the fact that we cannot store null values in the Context
> is due to the fact that we use a java.util.Hashtable in its implementation.
> If we used instead a java.util.HashMap we could store NULL values.
> Moreover, HashMap access is not syncronized, which given our usage
> of Context is unnecessary. That could even speed things up.

I tried that for both of those reasons, and was convinced it was slower
for whatever reason. Hm.  Maybe I will try again.

geir

> Jose Alberto

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity