Skip to content

Commit 71ad391

Browse files
committed
Docs about naming Primitives
1 parent b1226d5 commit 71ad391

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/contributor/primitives.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Primitives
2+
3+
## Naming
4+
5+
Primitives are generally named `#{module or class to which it belongs}_#{name of the operation}` such as `string_start_with?`.
6+
7+
The `object_` prefix should only be used for instance variables-related operations, like `object_ivars`.
8+
9+
For primitives which are not specific to a module or class, use no prefix, such as `Primitive.is_a?`/`Primitive.equal?`.
10+
11+
For primitives used in many places it is nice to have a shorter name.
12+
OTOH for primitives used in a single place, e.g., to implement part of the logic in Ruby, then a longer name is fine.

0 commit comments

Comments
 (0)