Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #1891
jonsequitur opened this issue Nov 2, 2022 · 6 comments
Open
Tracked by #1891

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

jonsequitur opened this issue Nov 2, 2022 · 6 comments
Labels
Area-API needs discussion Further discussion required
Milestone

Comments

@jonsequitur
Copy link
Contributor

jonsequitur commented Nov 2, 2022

No description provided.

@jonsequitur jonsequitur mentioned this issue Nov 2, 2022
56 tasks
@jonsequitur jonsequitur added Area-API needs discussion Further discussion required labels Nov 2, 2022
@jonsequitur jonsequitur added this to the 2.0 GA milestone Nov 9, 2022
@reduckted
Copy link

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
};

@KalleOlaviNiemitalo
Copy link

Was discussed in #2046 but not decided.

@andrewimcclement
Copy link
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.

@tkapin
Copy link
Member

tkapin commented Aug 23, 2023

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.

@lukewis
Copy link

lukewis commented Nov 17, 2023

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

@KalleOlaviNiemitalo
Copy link

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 .).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-API needs discussion Further discussion required
Projects
None yet
Development

No branches or pull requests

6 participants