Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename connect to join #1102

Merged
merged 2 commits into from Jul 8, 2015

Conversation

Projects
None yet
@barosl
Copy link
Contributor

barosl commented May 2, 2015

Kawaii version

Related Rust issue: rust-lang/rust#24645

@gkoz

This comment has been minimized.

Copy link

gkoz commented May 2, 2015

👍
Had to ask on irc to find out that join is called connect.

@gsingh93

This comment has been minimized.

Copy link

gsingh93 commented May 2, 2015

+1

Having a deprecated method in a newborn language is not pretty.

If we do remove the `.connect()` method, the language becomes pretty again, but
it breaks the stability gurantee at the same time.

This comment has been minimized.

@mdinger

mdinger May 3, 2015

Contributor

s/gurantee/guarantee/

@quantheory

This comment has been minimized.

Copy link
Contributor

quantheory commented May 3, 2015

I approve, though I don't have a strong opinion. I do want to point out that if stability is an issue, we can have two names for the same function, and deprecate the older one. As I understand it, the core team has decided that adding methods without changing/removing existing methods is considered backwards compatible, even though there's a small chance of a name clash when adding a method. Not allowing methods to be added would be just too restrictive, since the standard library would really not be able to evolve its existing types.

@tshepang

This comment has been minimized.

Copy link
Contributor

tshepang commented May 3, 2015

👍

@tshepang

This comment has been minimized.

Copy link
Contributor

tshepang commented May 3, 2015

I'd go as far as getting rid of concat, in favor of join(""). It feels like overkill to have a whole function just for that special case. I thought the advantage would be performance, but not even. Following:

#![feature(test)]
extern crate test;

#[bench]
fn connect(b: &mut test::Bencher) {
    b.iter(|| {
        ["foo", "bar", "baz", "qux"].connect(" ")
    });
}

#[bench]
fn concat(b: &mut test::Bencher) {
    b.iter(|| {
        ["foo", "bar", "baz", "qux"].concat()
    });
}

Gives:

test concat  ... bench:        82 ns/iter (+/- 14)
test connect ... bench:        79 ns/iter (+/- 7)
@andrew-d

This comment has been minimized.

Copy link

andrew-d commented May 3, 2015

👍 from me - this was something I had to look up too.

@gsingh93

This comment has been minimized.

Copy link

gsingh93 commented May 3, 2015

If we had done this earlier, deprecating/removing concat might have been fine, but I don't know if its worth doing it now. I don't have a strong opinion either way.

@bluss

This comment has been minimized.

Copy link

bluss commented May 4, 2015

Full support if we can deprecate the old names before 1.0, otherwise I think it's a silly change. We can live with a difference like this.

@tshepang

This comment has been minimized.

Copy link
Contributor

tshepang commented May 4, 2015

Why not deprecate even after 1.0 @bluss?

@bluss

This comment has been minimized.

Copy link

bluss commented May 4, 2015

I'm not entirely against it, it just seems we could live with the difference instead. The name is not exactly monumental mistake. The positive sides are that deprecation is easy and the warning message should mean that almost everyone uses the non-deprecated name, but it's still another extra entry in the docs.

@tshepang

This comment has been minimized.

Copy link
Contributor

tshepang commented May 4, 2015

@bluss a core team member is planning on having docs for deprecated items hidden by default

@gsingh93

This comment has been minimized.

Copy link

gsingh93 commented May 4, 2015

Since the trait is marked as unstable, will any code currently building with the beta actually break if the methods are removed?

@bluss

This comment has been minimized.

Copy link

bluss commented May 4, 2015

Yes, because the methods are callable in beta (playpen link)

fn main() {
    println!("{}", ["foo", "bar", "baz", "qux"].connect(" "));
}
@barosl

This comment has been minimized.

Copy link
Contributor Author

barosl commented May 4, 2015

@gsingh93 While the trait is unstable, the stable methods are already exported to the prelude. That's the problem!

@barosl barosl force-pushed the barosl:rename-connect-to-join branch from 753b28c to 568ed6a May 5, 2015

@ArtemGr

This comment has been minimized.

Copy link

ArtemGr commented May 6, 2015

👍 I've searched the docs for join a few times and came away empty-handed. Turns out it's there, but under an unexpected name. Let's maintain the principle of least astonishment.

@tanadeau

This comment has been minimized.

Copy link

tanadeau commented May 6, 2015

👍 I also had a lot of trouble finding this.

@robinst

This comment has been minimized.

Copy link
Contributor

robinst commented May 6, 2015

👍 was also looking for this under the name "join".

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Jun 11, 2015

The libs team has been working through the RFC backlog, and I wanted to restart discussion on this RFC.

Unfortunately, since 1.0 has shipped, the calculus here is perhaps a bit different than during the original comment period. In particular, since the connect method is stable, this would require a deprecation, along the lines discussed in this internals thread.

While I'm definitely sympathetic to the idea that matching existing precedent is good, I also feel that connect is a reasonable name (in some ways more evocative than join), and given that this would require a deprecation, I'm not personally sure it's worth it.

@Gankro

This comment has been minimized.

Copy link
Contributor

Gankro commented Jun 11, 2015

This seems like another great candidate for something like
#1150

On Thu, Jun 11, 2015 at 10:33 AM, Aaron Turon notifications@github.com
wrote:

The libs team has been working through the RFC backlog, and I wanted to
restart discussion on this RFC.

Unfortunately, since 1.0 has shipped, the calculus here is perhaps a bit
different than during the original comment period. In particular, since the
connect method is stable, this would require a deprecation, along the
lines discussed in this internals thread
https://internals.rust-lang.org/t/thoughts-on-aggressive-deprecation-in-libstd/2176/
.

While I'm definitely sympathetic to the idea that matching existing
precedent is good, I also feel that connect is a reasonable name (in some
ways more evocative than join), and given that this would require a
deprecation, I'm not personally sure it's worth it.


Reply to this email directly or view it on GitHub
#1102 (comment).

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Jun 11, 2015

I suggest interpolate, intercalate and intersperse as alternative renamings.

@ssokolow

This comment has been minimized.

Copy link

ssokolow commented Jun 11, 2015

The problem with connect is that, in a programming context, the verb has built up an implicit association with IPC, which might lead to an effect similar to banner blindness where people keep missing it because they "know" that's not what they're looking for on a level too low to realize that IPC support in strings makes no sense.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jun 16, 2015

This RFC is now entering its week-long final comment period.

@ArtemGr

This comment has been minimized.

Copy link

ArtemGr commented Jun 17, 2015

👍 We still need this even after 1.0, users still going to look for the familiar join in the APIs.

@DanielKeep

This comment has been minimized.

Copy link

DanielKeep commented Jun 18, 2015

👍 This bit me three times until I could finally remember what Rust called this method (the second and third times, all I could remember was "it's called something stupid which I expect to mean something else" and not the name).

This is a nasty newbie trap; I can't think of any good reason to not at least introduce join as a synonym.

@rkjnsn

This comment has been minimized.

Copy link
Contributor

rkjnsn commented Jun 19, 2015

👍 for join. I think it is worth the deprecation.

@rtkrruvinskiy

This comment has been minimized.

Copy link

rtkrruvinskiy commented Jun 20, 2015

👍 When first trying Rust, I spent a long time looking for this functionality under join and in the end failed to find anything. I eventually asked and was pointed to connect. Never in a million years would I have guessed the name.

I can definitely understand the reluctance to deprecate, but I think join should be a synonym even if connect stays.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 21, 2015

I am somewhat confused as to why this method is defined on slices in the first place as opposed to iterators. If I want to project strings out of a collection of structs and then join them, I'd currently have to collect them into a Vec first which seems unfortunate/unnecessary.

I'd like to see a proposal for the addition of a join API to Iterator (or maybe an extension trait?). I'm not sure if the basic signature that exists now is the right way to go either - should it return String/Vec<T> directly? Should it be passed a &mut String/&mut Vec<T> like some of the Read methods do? Should it be able to take a Writer to potentially avoid intermediate allocation?

EDIT: If the API moves to Iterator it might still be worth adding convenience methods to String and Vec, however.

@bluss

This comment has been minimized.

Copy link

bluss commented Jun 21, 2015

@sfackler When slices already are present, it's a great advantage to use that, because the implementations walk them twice, once to compute the exact space needed and once to do the concatenation.

When the slice is already present this is much superior, and it might even be more performant even when including a collect, depending on the number and length of the strings.

So that's the benefit of slices, that doesn't preclude a method on iterators. We absolutely should opt for consistency though — I'm in favour of .connect() on an iterator if that's the name that stays.

@gkoz

This comment has been minimized.

Copy link

gkoz commented Jun 22, 2015

@bluss I don't see why it has to be a slice if a clonable iterator is sufficient.

@tafia

This comment has been minimized.

Copy link

tafia commented Jun 22, 2015

I'm used to join in other languages too. connect make me think of more complicated operation (e.g. databases).

@jminer

This comment has been minimized.

Copy link

jminer commented Jun 24, 2015

👍 If I were looking for this method, I would look for join. I don't know if I would find it with its current name.

@Veedrac

This comment has been minimized.

Copy link

Veedrac commented Jun 24, 2015

I'm in favour of join on cloneable iterators and deprecating connect. I don't see the downside of using cloneable iterators and join is a far better name.

@Ryman

This comment has been minimized.

Copy link

Ryman commented Jun 24, 2015

@Veedrac I think the main downside currently is that rust-lang/rust#23501 is not implemented, so much of current iterator usage isn't currently cloneable?

@Veedrac

This comment has been minimized.

Copy link

Veedrac commented Jun 24, 2015

@Ryman That's not much of a problem, since it still leaves us in a strictly better situation whilst we're waiting.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 24, 2015

Why does the iterator need to be clonable? Being able to allocate the space up front does not seem to be sufficiently amazing to forbid join's use with non-cloneable iterators. We can always add an optimized version when specialization or something equivalent is implemented.

@nstoddard

This comment has been minimized.

Copy link

nstoddard commented Jun 25, 2015

👍

@devonhollowood

This comment has been minimized.

Copy link

devonhollowood commented Jul 1, 2015

I'm fine with adding join as a synonym, but getting rid of connect just doesn't seem worth it to me. I don't think the issue is big enough to warrant deprecation.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 1, 2015

The libs team did not reach consensus on this issue during this past FCP. To help focus the discussion though we think that the question of what this method is defined on (slices or iterators) is orthogonal to what it's called, so a future RFC can tweak this design but that's not quite the focus of this RFC.

Additionally it's probably not worth blocking this RFC on waiting for a system for renaming methods, so the only major objection to this is that it may not be worth the cost that it incurs (e.g. deprecating a method, straddling versions is harder, etc). The support here may be enough to outweigh this, however.

As a result we're going to leave this RFC in the FCP for another week.

@adwhit

This comment has been minimized.

Copy link

adwhit commented Jul 1, 2015

👍 Got bitten by this yesterday!

@yongqli

This comment has been minimized.

Copy link

yongqli commented Jul 1, 2015

👍

1 similar comment
@leodasvacas

This comment has been minimized.

Copy link

leodasvacas commented Jul 3, 2015

👍

@lambda

This comment has been minimized.

Copy link
Contributor

lambda commented Jul 4, 2015

👍 for join, and deprecating connect. May be a good idea to do add the new alias, wait some time, and then deprecate the old one, if you want to avoid the version compatibility issues that can come from immediately deprecating (lots of people switch all at once to silence the warnings, but then none of that code runs on old releases that may be present in various package managers). However, I think it's still early enough, and there are few enough (if any) platforms in which Rust is packaged in any kind of long-term supported release, that it's probably still fine to do immediate deprecation.

@nathankleyn

This comment has been minimized.

Copy link

nathankleyn commented Jul 6, 2015

👍 I agree with @lambda in regards to an eventual deprecation after a period of a stable alias. This bit me when I first tried rust as I was so used to it being called join in virtually every other language.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 8, 2015

After this next week of FCP the libs team is now in consensus to merge this RFC, so I shall do so. Thanks again for the discussion everyone and for the RFC @barosl!

Tracking issue

@alexcrichton alexcrichton merged commit 5b9a48d into rust-lang:master Jul 8, 2015

@tshepang

This comment has been minimized.

Copy link
Contributor

tshepang commented Jul 8, 2015

\0/

@chriskrycho chriskrycho referenced this pull request Feb 8, 2017

Closed

Document all features in the reference #38643

0 of 17 tasks complete

@chriskrycho chriskrycho referenced this pull request Mar 11, 2017

Closed

Document all features #9

18 of 48 tasks complete

@Centril Centril added the A-slice label Nov 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.