Skip to main content
16 events
when toggle format what by license comment
Sep 25, 2020 at 3:45 comment added LB2 Excellent answer (and I agree), but I'll add a small caveat: if problem domain has a word for it, then ok to use it. E.g. if you're writing mathematics set theory software library, then such library is already likely to make heavy use of math terminology (cardinality, compliment, cartesian product, etc), then it's ok to use terms from that domain - "singleton set" in this case - and having a class Set with a member Set.IsSingleton right along Set.cardinality and Set.IsNull as the term would be expected to be interpreted in that context domain.
Sep 24, 2020 at 6:47 comment added Peter - Reinstate Monica @devuxer Also, the "singular" in "singular list" is an attribute of list; but the list is not singular at all. "Singular item list" is much better. Or "single item list". Or "list_of_length_1" ;-).
Sep 24, 2020 at 5:36 comment added devuxer I agree with not trying to come up with a new word, but personally, I would just go with "single-item list". I think that's more clear than "singular list" (since "singular" can mean the opposite of plural, but it can also mean "extraordinary; remarkable; exceptional").
Sep 23, 2020 at 17:18 comment added Drew I disagree that singleton should be confined to use as a particular type of list (must contain one element) or confined to correspond to math uses. Context is everything. As long as it makes the meaning clear, it's perfectly fine for some context to use singleton to mean a list or set or ... that has a single element. Think of a game of bridge.
Aug 27, 2020 at 8:28 vote accept Terrence Brannon
Aug 26, 2020 at 12:29 comment added Lukas Körfer @Peter-ReinstateMonica Now we are at the point we need to decide whether we want to interpret the word singleton based on its original meaning or based on an (anti-)pattern with the same name.
Aug 26, 2020 at 12:11 comment added Peter - Reinstate Monica @LukasKörfer "In a mutable (programming) world we can only describe the current state": This is exactly the core issue.The word singleton describes all possible future states of the program: There will always be exactly one object (in that list, or in the entire program). We can obviously describe much more than "only the current state": We can make assertions about future states, and one such assertion is that a singleton will never have a second instance next to it. This cannot be said about a general list of size 1. It can be said, however, about java.util.Collections.singletonList.
Aug 26, 2020 at 12:00 comment added Lukas Körfer In a mutable (programming) world we can only describe the current state. When you call a list an empty list, you would only describe that one moment where it is actually empty. Once you added an item it is not empty anymore. Nevertheless we call lists (regarding to their current state) empty lists. In the same way we might call lists with only one item (regarding to their current state) singleton lists.
Aug 26, 2020 at 11:56 comment added Peter - Reinstate Monica @Lukas I find the immutability essential: Singleton implies there can be only one.
Aug 26, 2020 at 11:55 comment added Lukas Körfer @Peter-ReinstateMonica Just because the term empty list is more common it does not mean that singleton list is less precise. As other answers have already stated, there is no common or widely accepted term for a list with exactly one element, but the term singleton list or singleton set is pretty descriptive and may be used to express this context. Whether or not this list is immutable is completely unrelated to this terminology.
Aug 26, 2020 at 11:52 comment added Peter - Reinstate Monica @LukasKörfer This is, obviously, just my perception and experience; different groups of people and speakers from different regions use words differently. Your mileage may vary. Language is also dynamically evolving. In the end t is hard to be sure about anything with natural languages. My answer reflects my perception: That any of these words would be pretty substantially mislead (me). That said, typically I'm not the only one when it comes to language. I would bet that in a room of 10 programmers another one would think "singleton! Ah. I know *that" and be on a wrong trajectory.
Aug 26, 2020 at 11:47 comment added Peter - Reinstate Monica @LukasKörfer "Empty list" is a general term in computer science, denoting what it says. The contraction used to name Collections.EmptyList is derived from this general term. By contrast, at least to me singleton in software engineering is a specif term used by the gang of four to name the singleton pattern. Yes, it has usages outside this specific pattern, and even outside software, but if in the context of software somebody tells me "this is a singleton" I have a very specific idea of what they mean, and it is not a general list which just happens to have a single element in it.
Aug 26, 2020 at 11:34 comment added Lukas Körfer @Peter-ReinstateMonica According to this logic you may only call a list without elements an empty list if it is immutable, as the list provided by Collections.emptyList() is immutable. Immutability is just a completely unrelated property regarding this terminology.
Aug 26, 2020 at 9:42 comment added Peter - Reinstate Monica @JörgWMittag The Java API calls that a singleton if only exactly one element can be in the list. That "Highlander paradigm" is not at play in the OP's case. Calling a general list which just happens to have one element a singleton is plain misleading.
Aug 26, 2020 at 9:26 comment added Jörg W Mittag "Do not come up with a new word" – I 100% agree. The Java API calls this a singleton list, and Java is one of the most widely used programming languages. So, don't come up with a new word, just stick with what Java already uses.
Aug 26, 2020 at 8:49 history answered Peter - Reinstate Monica CC BY-SA 4.0