Christoph :
> Getting there...
> A valid solution for me is to "Drop the key from the context if the value
is null".
Me too. Keeps it clean and consistant.
I guess that begs the question, in the java-layer Context interface, do we
declare that if you do a put( key, null ) we *remove* the key from the
context? that would be the consistant thing to do...
>"Geir Magnusson Jr." wrote:
>>
>> Christoph :
>> > My experience shows me these situations where a NULL can happen.
>>
>> > a) The template designer has written an invalid identifyer:
>> > #set( $foo = $bar.woobie )
>> > where getWoobie() does not exists. here it is sufficient that
>> > its logged...
>>
>> Yes, that will be logged. It is actually checked before it's shoved into
>> the context, so the only issue there is that $foo is still not in the
>> context if it wasn't, or unchanged if it is. Maybe to support the
semantics
>> of 'no null references' we just remove $foo from the context ?>
> If you make 'no null references' configurable some others will scream,
> saying this will counteract velocimacro libraries...
I don't think it should be configurable. That would be an unholy mess. We
should decide one way or the other.
>>[snip]
>> right. Hm. Maybe if you do what amounts to a #set( $foo = <null value
>> returned from something> ) then we remove $foo from the context if it is
>> there? That would support the semantics, be predictable, etc.
>+1
>> This strikes
>> me as a little yecchy though, somehow, although in some ways clean :
there
>> are no null objects in the context.
>It seems clean from the context point of view: Context is a list of
>objects accessible by a name (key). NULL is not a object, therefore
>cannot be in the context. Setting something to NULL, removes the key
>from the context.
Yep. That's a great way of putting it, and exactly what I was getting at :
lets have a clean description of the context, and thats a clear one for the
'no nulls' camp. (where I live...)
>> It also makes the proposed addition of
>>
>> #if( $foo == NULL )
>>
>> as a not-a-reference check clean.
>+1 if the context cannot contain nulls, otherwise #if( $foo == $NULL )
Yeesh! Hopefully not '$NULL' ? :)
> Note that the access to nonexistent $foo in a production environment
> should not emit any log messages, as 2) in your proposal (this thread).
Agreed 100%, and there is a switch already :
runtime.log.reference.log_invalid set = true if you want the logging,
false if not. default is true
>>[snip]
>> >Somebody already said in this list "NULL is your friend".
>>
>> That was Jose or Daniel, I think. I don't quite get why though. I do in
-------------------^^^^^^
>> Java, but in template land? I guess one will be able to find uses, but
if
>> you formalized things from the Java side by adding booleans to tell you
>> about valid data... I dunno. That's extra work. Just hoping to get
things
>> clean, and describable in documentation in as few lines as possible.
Was that you?
>And with the clean definition (see above) of the Context API, I agree
>we can avoid having NULL context keys and values. Keys make no sense
>and NULL values are avoided by removing the key!
right.