Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capital letters for named patterns

In Mathematica built-in Symbols start with capital letters. Therefore it is accepted practice to not start user created symbol names with capital letters.

How far should this restriction be extended to other aspects of syntax? Does good practice demand that a capital letter not be used for a named pattern in a SetDelayed or RuleDelayed expression (where such names are localized)?

I think that capitals expand the namespace in a useful way and visually distinguish between lowercase L and 1, for example. They also allow arguments to be named in a textbook fashion.

If new symbols are introduced in future versions, the named patters should supersede these, and existing code should not break.

A con is ambiguity if existing names such as N and D are used, but I feel that both the context of use and FrontEnd syntax highlighting mitigate this.

like image 376
Mr.Wizard Avatar asked Nov 05 '11 06:11

Mr.Wizard


People also ask

Should names of things be Capitalised?

In general, you should capitalize the first word, all nouns, all verbs (even short ones, like is), all adjectives, and all proper nouns. That means you should lowercase articles, conjunctions, and prepositions—however, some style guides say to capitalize conjunctions and prepositions that are longer than five letters.

Do you capitalize shape names?

Special Cases: Capitalize the letters used to indicate form or shape. Capitalize words like “sociology” and “history” when they are used as titles of specific courses; do not capitalize these words when they name a field of study.

What are the rules for capitalizing titles?

According to most style guides, nouns, pronouns, verbs, adjectives, and adverbs are capitalized in titles of books, articles, and songs. You'd also capitalize the first word and (according to most guides) the last word of a title, regardless of what part of speech they are. Be the best writer in the office.

What are capitalized random letters called?

Alternating caps, also known as studly caps or sticky caps (where "caps" is short for capital letters), is a form of text notation in which the capitalization of letters varies by some pattern, or arbitrarily (often also omitting spaces between words and occasionally some letters), such as "aLtErNaTiNg cApS", "sTuDlY ...


1 Answers

This is an accepted practice that I do not accept!

I am referring to packages, for personal or 3rd party use. In general I want my finished work to be as indistinguishable as possible from the ideal (WRI) quality,look and feel. This includes long descriptive names for my commands, with all the capitalization conventions used by WRI.

Of course my packages are - at the moment - nowhere near WRI quality, but at least I am trying to integrate them as best as I can with standard MMA functionality. And this includes having capitalized commands.

During development, syntax highlighting alerts me of possible conflicts with standard MMA functions, so I can take appropriate actions. Of course my commands and packages may conflict with future releases of MMA, but nothing lasts forever and if a future MMA command is similar in name and functionality to one of mine, I will simply switch to the standard function with minimal or no change in naming.

Besides this, I find visually much more appealing to use capital letters to distinguish package commands from more modest temporary variables. If you want to see some visually opaque/unappealing code, just look at any average Maple code.

Regarding pattern variables, I try to give meaningful, mostly short, pattern names with no capitals, so the user can guess by looking at the Ctrl/Cmd-K template what kind of input is expected in my package commands.

like image 104
magma Avatar answered Sep 16 '22 11:09

magma