28

When working on How could we make [todictionary] less ambiguous? I came across questions with the tag.

It has all the same problems as the tag:

No tag wiki, no description, a function name in .NET that is nothing special. It doesn't do anything differently than all the other functions in the .NET framework. Since it literally takes no parameters and has no side effects, I don't see how one can ever be an expert in .ToList() other than typing it faster than others.

I will self-answer this, but please add your own answers if I overlooked anything. Maybe it's really important and valuable in other languages and just needs a tag wiki to make sure it's used for only those.

10
  • 1
    Note that there are about twice as many questions with tolist compared to todictionary. Also, it's not as limited as the other one to C# and pandas. terraform, flutter and probably a few other usage contexts are also there. Someone who knows about those should probably look at them and see if a tag like this might be useful there.
    – MegaIng
    Jan 4, 2022 at 12:06
  • 2
    @MegaIng a tag for a single function is never useful, and just serve to reinforce the idea that tags are hashtags instead of topics.
    – Braiam
    Jan 4, 2022 at 12:25
  • @MegaIng I have no experience in pandas and terraform, but with flutter/dart it's the same as with C#. Yes, it exists. It isn't special in any way.
    – nvoigt
    Jan 4, 2022 at 12:30
  • 1
    Java also has Collectors.toList() but it's similarly not really special and unlikely to really require a tag for itself. I think that in general, tags for functions/methods/properties are unneeded. Maybe for some but that should be very rare. Most of the times I find that tagging the function/method/property is an XY problem.
    – VLAZ
    Jan 4, 2022 at 12:55
  • 1
    @Braiam Yes of course. If it's just a non special function the tag can just be removed. I don't know whether or not that is true for all those other topics as well. The question therefore is if nvoigt's answer applies to all topics that this tag is used in.
    – MegaIng
    Jan 4, 2022 at 13:10
  • 4
    "[tolist] or not [tolist]" Jan 5, 2022 at 14:20
  • @nvoigt want to start one for [toarray]? Jan 6, 2022 at 17:55
  • cleaned up within .net, c# and vb.net Jan 6, 2022 at 18:14
  • To me it seems like a waste of time removing these kinds of tags. What problems exactly are they causing which merit their removal? Also, what's with the jokey names like "unlist [tolist]"? Jan 6, 2022 at 21:41
  • @trinalbadger587 last question. Also, it's not about what causes harm, is about what value it provides. The only way that a high quality library is achieved is by setting a high bar. Mediocre content (or tags) can't be allowed.
    – Braiam
    Jan 6, 2022 at 22:51

2 Answers 2

37

Just remove it.

The tag provides zero value for . The ToList method is nothing special, does not act special, has no special compiler support that would set it apart from any other method in the .NET Framework (or .NET Core or .NET 5 or 6 or any other).

We do not need one tag per method.

While IEnumerable is a very special interface that does special things and has special compiler support, therefore deserving a tag, IList and ToList do not.

I cannot speak for other languages, but I would suspect it's the same there. If it's relevant for other languages, it should be clearly marked as such and then removed from all C# questions.


Since it came up: the same goes for the or more precisely function of the same name.

11
  • 2
    Java. Jan 4, 2022 at 14:01
  • 3
    I'm not arguing against removing the tag, but in .NET, .ToList is a bit special. It's the idiomatic way to materialize a collection (when using LINQ-based technologies, the result you get is typed as an IEnumerable<T> (i.e., a collection of T), but the actual items in the collection are not gathered into a real collection until the collection is enumerated (for example in a foreach statement or a .ToList call). I'm only saying the .ToList method is not "nothing special". It's something that takes newbies a bit by surprise
    – Flydog57
    Jan 4, 2022 at 18:45
  • Well, as I said in my answer, the special case is IEnumerable<> that behaves different from other interfaces. ToList materializes IEnumerables, but so does any other method that enumerates the IEnumerable. So if anything takes newbies by surprise, it's IEnumerable.
    – nvoigt
    Jan 4, 2022 at 18:55
  • 1
    @Flydog57, it is IEnumerable which is special. deferred execution surprises many, not only newbies. ToList works just as well with array . but .ToList().ForEach() combo is a special evil.
    – ASh
    Jan 4, 2022 at 19:41
  • 5
    It may be something that takes newbies by surprise, but unless the newbies know that the ToList in their code (or perhaps more often, the lack of it?) is what's causing a problem, then they won't know to use the tag anyway.
    – kaya3
    Jan 4, 2022 at 22:53
  • @Flydog57 Just because c# IQueryable<T>.ToList() is a shortcut to iterate over and therefore realise the results of an expression, it is ambiguous to tag a related question with [ToList], tagging with expression or Linq or Linq-to-XXXX variants is more useful. .ToList() is the least significant component to debugging a linq expression (other than a common point where execution occurs) it is not the only command that can be used to evaluate the expression which further adds to the ambiguity. Jan 5, 2022 at 11:54
  • 1
    For c# and .net I think the linq tag is sufficient here also, as well as a language and/or framework tag if one is missing (e.g. How to convert LINQ query result to List?.)
    – dbc
    Jan 5, 2022 at 19:52
  • 1
    Why not merge it into [list]?
    – Laurel
    Jan 5, 2022 at 22:35
  • @Laurel why should we? Why shouldn't we just delete it?
    – Braiam
    Jan 6, 2022 at 10:57
  • @Braiam It only takes a minute to merge it (or make a synonym) with none of the drawbacks of manual editing (time consuming, bumps). Plus, not all questions there have the list tag.
    – Laurel
    Jan 6, 2022 at 12:03
  • @Laurel None of those "drawbacks" seems drawbacks to me, meanwhile your solution is full of the same drawbacks this solution fixes, merging or synonimizing will keep a bad tag on questions.
    – Braiam
    Jan 6, 2022 at 12:17
4

In addition to the fact that the C# ToList() function really isn't that hard to use and doesn't merit its own tag, I would like to add that this is actually rather ambiguous. It's used for numerous different languages, including C#, VB.NET, Python, Java, and even occasionally C++, with no one use being more "correct" than any of the other uses. The odds of someone actually knowing about all of those things seems quite low, and it's really not identifying a unique programming topic.

This tag should be removed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .