[stringtemplate-interest] null vs missing vs empty vs nonexistent
Jonathan Buhacoff
jonathan at buhacoff.net
Fri Oct 16 21:31:45 PDT 2009
Hi, I've been lurking but would like to add my perspective here:
Where I grew up, null means missing value. I think it would be a
mistake to make a distinction between a key that was set with a
missing value, and a key that wasn't set at all. Either way the value
is missing.
I think having an operator like ifnull is a great feature to have for
template authors that care for the difference between false and missing.
I also think that the if operator should treat null as false, for all
the template authors who care only if the value is defined and true.
I think that ifempty, trim, and other such variations should be left
to the model, perhaps by wrapping strings with an object that
implements toString and also trim(), isEmpty(), etc. so that the
template writer can make distinctions like $ifnull(value)$,
$if(value.isEmpty)$ and $if(value.trim.isEmpty)$
Jonathan
On Oct 15, 2009, at 8:04 PM, Zenaan Harkness wrote:
* there is no attribute named "foo"
* there is an attribute named "foo", and its value is : null
* there is an attribute named "foo", and its value is a string,
which is : "...(whatever, including the empty string)"
Maybe a fourth case to test if the value is the empty string
could be relevant, and this would autmatically lead to a fifth
case where the trimmed value (removing all spaces, tabs,
form feeds, vertical form feeds, ...) is the empty string.
On Oct 15, 2009, at 8:04 PM, Zenaan Harkness wrote:
> (Again, to all, please make an effort to bottom-post, where at all
> possible, if no objections to doing so. Thanks.)
>
> On Thu, Oct 15, 2009 at 02:25:43PM -0700, Graham Wideman wrote:
>>
>> At 10/15/2009 01:56 PM, Terence Parr wrote:
>>> was thinking about that but figured it'd confuse. we have <if(!
>>> foo)foo
>>> is missing<endif> anyway.
>>
>> ...though ! appears to have two problems for detecting the missing
>> case: it doesn't distinguish between FALSE and null (and missing if
>> missing is legal here), and docs I think probably aren't clear on
>> whether the missing case is legal and treated like null, or should
>> cause error.
>>
>> Generally I think if you establish missing as a concept distinct
>> from null, then to minimizing confusion means that everywhere those
>> concepts arise they should get distinct treatment (eg: parallel
>> options in render).
>
> Graham this is an excellent, and I must add, very important point.
>
> There have been >1 times when I have been frustrated with the concept
> limitation and ambiguity/ overloading, of boolean value (true/false)
> as
> compared with null and/ or missing.
>
> In reality, we-the-template-authors have to handle (in some way or
> other) the three concepts:
>
> - boolean
> - null
> - missing attribute
>
> Should all three concepts be compressed into boolean?
>
> Should they be separate?
>
> Notwithstanding if separate boolean, should null and missing be
> separate
> or combined?
>
>
> Again, I have to strongly agree here with Graham - if the concepts are
> treated separately somewhere, they ought to be, if possible, treated
> as
> separate concepts _everywhere_.
>
>
>> This of course runs into trouble applying boolean operators to what
>> is now becoming a 4-value situation: true-val/false-val/null/
>> missing --> true/false/maybe-error.
>>
>> :-(
>>
>> No time as good as a new version to take a stand though!
>
> ACK!
>
>
>> (BTW, are you really saying there are also empty and nonexistant
>> cases?)
>>
>> Graham
>>
>>
>>> Ter
>>> On Oct 15, 2009, at 1:53 PM, Graham Wideman wrote:
>>>
>>>> If you're worried about whether the missing case should or should
>>>> not be treated like null, might you consider a missing="something"
>>>> option to parallel null="something"?
>
> If the concepts are treated distinctly somewhere, consistency
> dictates,
> once again, that the concepts are treated distinctly everywhere. So
> yes,
> null="blah" and empty="foo" (or non="foo" or whatever).
>
> Similarly, the conditionals:
>
> - if (for true/false)
> - ifnull
> - ifempty
>
> - etc for other parts of ST lang
>
> Consistency of concept treatment is essential!
>
>
>>>> At 10/15/2009 12:25 PM, you wrote:
>>>>> Ok, we have an important choice to make. Thanks to Bill Venners
>>>>> were
>>>>> bringing this up last year. It's important enough and long enough
>>>>> that
>>>>> I added to my blog:
>>>>>
>>>>> http://tinyurl.com/parrt-on-null-attributes
>>>>>
>>>>> Here is my summary from the bottom of the page:
>>>>
>>>> _______________________________________________
>>>> stringtemplate-interest mailing list
>>>> stringtemplate-interest at antlr.org
>>>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> --
> Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
> Please respect the confidentiality of this email as sensibly
> warranted.
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list