New Issue: Property queries: paren-less or paren-ful?

17128, “vasslitvinov”, “Property queries: paren-less or paren-ful?”, “2021-02-09T07:27:52Z”

Should methods that return properties of a datatype - such as size, emptiness, etc. - be parenless or have parenthesis?

Consider the range type as an example. It has the following “property” methods:

intIdxType isBounded hasLowBound hasHighBound stride alignment aligned first last low high alignedLow alignedHigh isEmpty size hasFirst isNaturallyAligned isAmbiguous

Should they be parenless or parenful or …?

Here are key points from our range module review on 2/04:

  • Methods for field-like properties should be paren-less.
  • Methods that can be reasonably expected to perform computation should have parens.
  • The above, however, will leave the user guessing whether a particular property is field-like or computation-like. Even among the range queries above, it is easy to guess incorrectly.

Our resolution was to make this a matter of style – and state it clearly in the documentation:

  • Methods whose names start with is or has have parens.
  • Methods with the other names are parenless.

Parenthezation in the range module today follows this style. Of particular note are size and isEmpty because they are standard queries among many datatypes in our modules and are parenless (for size) vs. paren-ful (for isEmpty) consistently.