Re: Standard library praise and challenge
- Posted by DerekParnell (admin) Sep 14, 2011
- 3170 views
One can say {} is the empty sequence. True.
However that is not the case when you are comparing atoms. {} has no atom, nothing, NULL. Hence when the sequence is flattened the empty sub-sequences disappear (just as in SQL, NULLs are ignored).
I can see what you're saying but one must not mistake an empty list for NULL. It really is not the same thing in Euphoria. While Euphoria does have a true NULL value, it is only used internally and we do not expose it to the coder. The NOVALUE value is not settable nor does the coder have a way to test for it. Maybe we should make this available for coders to use?
It leaves the problem of what to do with max(NULL) and min(NULL). They should return nothing ({} or NAN). It is odd to call it an error since this would imply that min({{},1}) should also be an error as it is saying:
"which is smaller nothing or 1?"
I see the problem of min({{},1}) differently. To me this is saying, of all the atoms in the argument, which is the smallest. In this case, the answer is 1 because that is the only atom in the argument.
Likewise, min({}) is also saying, of all the atoms in the argument, which is the smallest. In this case, the question is meaningless because there are no atoms in the argument. That is why I'm saying that this situation needs to return a value that means that nothing can be returned.