aRrgh icon indicating copy to clipboard operation
aRrgh copied to clipboard

Dot names

Open jonocarroll opened this issue 8 years ago • 2 comments

Dots in identifier names are just part of the identifier. They are not scope operators. They are not operators at all. They are just a legal character to use in the names of things. They are often used where a normal human being would use underscores, since underscores were assignment operators in S, which I promise you don’t even want to think about.

I'm not sure if you're still updating, or what your understanding is at this point, but this bit is slightly off. Dots are used in function names for method overloading (by class), so print(x) dispatches differently depending on the class of x.

For example, print(data.frame(x)) actually calls print.data.frame(x), but you may want to call print.default() explicitly.

jonocarroll avatar Aug 05 '16 08:08 jonocarroll

It's still true that they are not any sort of operator; the method overloading code just understands certain magical names that happen to use . as a separator and dispatches to them at runtime.

I should really add a section on the different class systems!

tdsmith avatar Aug 26 '16 05:08 tdsmith

Also a leading dot in a name will make it "special" in some sense, e.g., ls will not return its name unless 'all.names' is set to TRUE. Also isolated dots have been taken over as meaningful in tidyverse syntax. Arguably this does require consideration of scope.

dwinsemius avatar Oct 26 '19 22:10 dwinsemius