Skip to content

Commit 568ed6a

Browse files
committed
Add a draft for rename_connect_to_join
1 parent 92bc7a3 commit 568ed6a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

text/0000-rename-connect-to-join.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
- Feature Name: `rename_connect_to_join`
2+
- Start Date: 2015-05-02
3+
- RFC PR: (leave this empty)
4+
- Rust Issue: (leave this empty)
5+
6+
# Summary
7+
8+
Rename `.connect()` to `.join()` in `SliceConcatExt`.
9+
10+
# Motivation
11+
12+
Rust has a string concatenation method named `.connect()` in `SliceConcatExt`.
13+
However, this does not align with the precedents in other languages. Most
14+
languages use `.join()` for that purpose, as seen later.
15+
16+
This is probably because, in the ancient Rust, `join` was a keyword to join a
17+
task. However, `join` retired as a keyword in 2011 with the commit
18+
rust-lang/rust@d1857d3. While `.connect()` is technically correct, the name may
19+
not be directly inferred by the users of the mainstream languages. There was [a
20+
question] about this on reddit.
21+
22+
[a question]: http://www.reddit.com/r/rust/comments/336rj3/whats_the_best_way_to_join_strings_with_a_space/
23+
24+
The languages that use the name of `join` are:
25+
26+
- Python: [str.join](https://docs.python.org/3/library/stdtypes.html#str.join)
27+
- Ruby: [Array.join](http://ruby-doc.org/core-2.2.0/Array.html#method-i-join)
28+
- JavaScript: [Array.prototype.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
29+
- Go: [strings.Join](https://golang.org/pkg/strings/#Join)
30+
- C#: [String.Join](https://msdn.microsoft.com/en-us/library/dd783876%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396)
31+
- Java: [String.join](http://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.Iterable-)
32+
- Perl: [join](http://perldoc.perl.org/functions/join.html)
33+
34+
The languages not using `join` are as follows. Interestingly, they are
35+
all functional-ish languages.
36+
37+
- Haskell: [intercalate](http://hackage.haskell.org/package/text-1.2.0.4/docs/Data-Text.html#v:intercalate)
38+
- OCaml: [String.concat](http://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html#VALconcat)
39+
- F#: [String.concat](https://msdn.microsoft.com/en-us/library/ee353761.aspx)
40+
41+
Note that Rust also has `.concat()` in `SliceConcatExt`, which is a specialized
42+
version of `.connect()` that uses an empty string as a separator.
43+
44+
# Detailed design
45+
46+
While the `SliceConcatExt` trait is unstable, the `.connect()` method itself is
47+
marked as stable. So we need to:
48+
49+
1. Deprecate the `.connect()` method.
50+
2. Add the `.join()` method.
51+
52+
Or, if we are to achieve the [instability guarantee], we may remove the old
53+
method entirely, as it's still pre-1.0. However, the author considers that this
54+
may require even more consensus.
55+
56+
[instability guarantee]: https://github.com/rust-lang/rust/issues/24928
57+
58+
# Drawbacks
59+
60+
Having a deprecated method in a newborn language is not pretty.
61+
62+
If we do remove the `.connect()` method, the language becomes pretty again, but
63+
it breaks the stability guarantee at the same time.
64+
65+
# Alternatives
66+
67+
Keep the status quo. Improving searchability in the docs will help newcomers
68+
find the appropriate method.
69+
70+
# Unresolved questions
71+
72+
Are there even more clever names for the method? How about `.homura()`, or
73+
`.madoka()`?

0 commit comments

Comments
 (0)