Re: TIP #185: Null Handling
From: David S. Cargo (escargo_at_skypoint.com)
Date: 04/15/04
- Next message: Bryan Oakley: "Re: Stupid (very) question about menu Widget"
- Previous message: R. T. Wurth: "Re: LDAP"
- In reply to: John H. Harris: "TIP #185: Null Handling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 14 Apr 2004 19:35:47 -0500
John H. Harris <JHHarris@valley.net> wrote:
>
> TIP #185: NULL HANDLING
This reminds me of the "null" value in Icon. The null value in Icon
is the value assigned to all identifiers initially. (One of the
interesting ways that languages differ is in how they handle the use
of an uninitialized variable. If I remember correctly, in awk an
uninitialized variable is treated as having a value of the empty
string. In perl it was either the empty string or 0, depending on
context (if I remember correctly.)
There are simple operations to test for values being null or nonnull.
However, in most cases uses of variables with null values are errors.
You can assign the null value to variables.
There gets to be language-specific distinctions between undeclared
variables, uninstantiated variables, variables with unassigned values,
and variables with empty values.
In tcl, if you unset a variable, the variable goes away, not its
value.
I probably would be more inclined to something along the lines of
Icon, where variables can have a null value, but using for anything
except for testing it for a null value is an error.
The only other context where I can see this being of use might be in
procedure calls where there might be optional parameters. With a
procedure definition like
proc withDefaults { {a "a"} {b "b"} {c "c"} } {
puts $a
puts $b
puts $c
}
You could call this with [withDefault <null> B <null>] and get
a
B
c
Code that depends on all parameters after a null parameter being null
(which seems possible, but unlikely) would have that assumption
broken.
escargo
David S. Cargo (escargo@skypoint.com)
- Next message: Bryan Oakley: "Re: Stupid (very) question about menu Widget"
- Previous message: R. T. Wurth: "Re: LDAP"
- In reply to: John H. Harris: "TIP #185: Null Handling"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|