Skip to content

Consider a more commonly-known word than "arity" #1893

Closed as not planned
Closed as not planned

Description

@jonsequitur
No description provided.

Activity

  1. added
    needs discussion
    on Nov 2, 2022
  2. added this to the 2.0 GA milestone on Nov 9, 2022
  3. reduckted commented on Nov 11, 2022

    @reduckted

    What about ValueCount?

    public readonly struct ArgumentValueCount : IEquatable<ArgumentValueCount> {
        // ...
    }
    public abstract class Argument {
    
        public ArgumentValueCount ValueCount { get; set; }
    
        // ...
    
    }
    public static readonly Argument<FileSystemInfo?> Target = new("target") { 
        ValueCount = ArgumentValueCount.ZeroOrOne
    };
  4. KalleOlaviNiemitalo commented on Feb 28, 2023

    @KalleOlaviNiemitalo

    Was discussed in #2046 but not decided.

  5. andrewimcclement commented on Mar 15, 2023

    @andrewimcclement
    Contributor

    Given that Arity has exactly the desired meaning, would it be better to provide a suitable summary comment for people unfamiliar with the term? Part of my concern is that as soon as I see something like Count or Number I expect an integer type, which is incorrect in this instance.

  6. tkapin commented on Aug 23, 2023

    @tkapin
    Member

    I just stumbled upon this issue when checking the API changes (listed in #1891). Since it's open for discussion, I'd like to support the opinion to keep using the term "arity". While this term might not be recognized by many developers (for example by folks who don't have formal mathematical or computer science education), it expresses the entity exactly (see Arity on Wikipedia for reference) and makes perfect sense to people familiar with the term.

    Another benefit of using the proper formal term "arity" rather than an approximation is also an educational effect. It expands people's knowledge ("Oh, that's how this thing is called!") and helps to coin the right terminology which in turn results in better understanding between developers.

  7. lukewis commented on Nov 17, 2023

    @lukewis

    After reading through #2046 , I'm happy to have a dedicated space (here) to discuss this. I'm afraid I don't have a perfect answer to this question (I suggest a few "less than ideal" possibilities in #2292) , but I very much appreciate the discussion.

    I don't think anyone refutes the "correctness" of the term Arity. It's more a problem of "discoverability". By sharing some of the story of how I came to "discover" this property (below), I hope to raise some awareness on the importance of choosing terminology that is "ubiquitous" (any DDD fans?) across the developer community.

    • I wanted to build a commandline app where the user would be prompted (inquirerjs style) for any arguments not provided
    • When I began using System.CommandLine (2.0.0-beta4.22272.1), it appeared that ALL arguments were "Required" (as in, you'd get an error if they were missing). I knew that Option had a property called IsRequired, so I looked to see if Argument had a property like that (it did not)
    • Next I went to a google search for "System.CommandLine optional argument" and came up empty
    • After deciding that the library must not support what I'm trying to do, I began "hacking around" the problem
    • I would call GetValueForArgument() and catch the exception thrown if the argument was missing. This lead me to discover an (unrelated) bug and post an issue ParseResultVisitor.ValidateAndConvertArgumentResults returns incorrect value for missing argument #2292 here on github, where one of the helpful contributors mentioned the usage of Arity (which I then had to google). Despite being a software engineer of 15 years, I had never before encountered that term.

    If I hadn't discovered a bug, cared enough to dig deeply into the source written a github issue, and gotten lucky when a contibutor responded and "happened" to mention a term I'd never heard before in their response, it's very possible I never would have discovered this property.

    I'm also not a fan of the term Cardinality (discussed in the other thread) for the same reasons. This term I've heard of, but not often enough to memorize the definition.

    Until I looked at the possible values for Arity, I also did not realize that a single argument accepting multiple values was even a possibility (nor do I fully understand the use case or how that would look in example commands). Would it be something like this (where pepperoni, sausage, ham are modeled as a single argument with Arity = ZeroOrMore)? Can someone help with a real-world example of when this is used?

    restaurant order pizza pepperoni sausage ham
    
  8. KalleOlaviNiemitalo commented on Nov 17, 2023

    @KalleOlaviNiemitalo

    Parsing similar to ZeroOrMore is usual in Unix utilities that take a list of file names, e.g. cat or ls; it works nicely together with wildcard expansion (globbing) in the shell. Typically though, if the list is empty, then each utility uses some default value instead: cat reads from standard input (like cat -) and ls lists the working directory (like ls .).

  9. teneko commented on Feb 10, 2025

    @teneko

    Another way to express ArgumentValueCount may be ArgumentVariability, ArgumentFrequency, or as mentioned earlier, ArgumentCardinality. I also have my eye on ArgumentMultiplicy, ArgumentQuantity or simply more correct ArgumentArity. I doubt it that humanity is resilient against learning, when they use "console parsing technology" in their projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-APIneeds discussion

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions