[stringtemplate-interest] null vs missing vs empty vs nonexistent
Zenaan Harkness
zen at freedbms.net
Sat Oct 17 01:47:49 PDT 2009
On Fri, Oct 16, 2009 at 09:31:45PM -0700, Jonathan Buhacoff wrote:
> Hi, I've been lurking but would like to add my perspective here:
>
> Where I grew up, null means missing value.
Hm. Must be a regional thing.
:) Couldn't resist sorry..
> 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.
What about a key (String) with value "" ?
This is strictly EMPTY as opposed to either NULL _or_ MISSING entirely.
Question is, how much to provide as _possible_ within pure ST, and how
much to push onto view-model.
> 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 have needed (and used the crude support for) if 'empty'.
Can you imagine real world cases where it's needed to handle the
differences between:
- TRUE vs FALSE
- "TRUE" vs "FALSE"
- attribute present vs no attribute present
- attribute NULL vs attribute has a value
- attribute = "" vs attribute !null, and "some string"
- attribute = "" or " " or "\t", vs attribute contains
"non whitespace"
> 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.
How would this be implemented? A per-ST option?
Or perhaps:
<names:{n | ...}; null=FALSE, empty=NULL>
<names:{n | ...}; null=EMPTY, empty=NULL> :)
<names:{n | ...}; null=FALSE, empty=FALSE>
??
> 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)$
Good points. The ongoing question of course, is how much is good to put
into ST, and how much to require view-model munging.
If in ST, how do you feel about:
<names:{...}; trim=TRUE; empty=FALSE>
?
cheers
zen
--
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.
More information about the stringtemplate-interest
mailing list