Take a simple example:
string1 = ""
string2 = "foo"
string1
is empty or null, which is clear.
But what about string2
? I wouldn't call it "full". "Non-empty" or "non-null" works, but is there not a single word that unambiguously captures the meaning of "not empty" in the context of a string?
-
1In the context of mathematics, it would probably be called "nontrivial." I don't know of any term in CS.David Pement– David Pement12/23/2020 14:57:41Commented Dec 23, 2020 at 14:57
-
1If the downvoter can suggest any way to improve this question, that would be appreciated!Lou– Lou12/23/2020 15:17:33Commented Dec 23, 2020 at 15:17
-
2Part of the community here downvotes every "name that thing" question categorically (which would be ok for me if they would leave a comment on it, which they usually don't). When you read this old meta post from 2014, there was IMHO not a real consensus of a question like this one should be accepted. The community today is even more picky about it. ...Doc Brown– Doc Brown12/23/2020 16:53:05Commented Dec 23, 2020 at 16:53
-
1What is the context (reasoning) that necessitates a single-word terminology for non-empty strings? Please explain.rwong– rwong12/23/2020 17:35:24Commented Dec 23, 2020 at 17:35
-
2@rwong - I'm writing code that frequently distinguishes between empty and non-empty strings - in my notes it's personally a bit annoying to not have an obvious conciser way to refer to non-empty strings.Lou– Lou12/24/2020 10:11:50Commented Dec 24, 2020 at 10:11
3 Answers 3
A variable that is assigned a value is said to be "populated."
That's about as close as you're going to get, unfortunately. A populated string variable (or a string of non-zero length) is just not interesting enough in and of itself to ascribe a single-word term.
-
Huh, I suspected this would be the case, but thanks. Your display pic is beautiful, by the way ;-)Lou– Lou12/23/2020 15:40:50Commented Dec 23, 2020 at 15:40
At least one of the languages I use, chose the pragmatic solution: nonempty
. Bam. One word.
As well as endorsing Robert Harvey's word "populated", I'd like to suggest the words replete
or even impleted
as the opposite of empty.
Although these words are more or less a synonym of "full", and perhaps even over-fullness and excess, in this context they're far more unusual words than "full" with fewer connotations of wholeness or limited capacity, and a stronger connotation of there being a complement of one or more individual items present (which is the same connotation that "populated" carries).
For example, you can use "full" like "he ate a full cake", which means the entirety of a single cake, not multiple cakes. Or "the dungeon was full" strongly suggests that it has reached its capacity, not that it is merely populated. These are connotations which make it unsuitable to talk of a "full string", which can be as little as one character or an indefinite number of characters.
They're also snappy words and not needlessly long to write or pronounce.
I seem to remember a similar question arising recently, and should I myself encounter a need to describe something (a container, array, string, etc.) that is "nonempty", I think "replete" may well be the word I turn to.
Correspondingly, I could well envisage myself generically describing a string that consists only either of a null, an empty string, or whitespace, as "nonreplete".