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

String Additions #166

Closed
wants to merge 4 commits into from
Closed

String Additions #166

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 21, 2014

String capitalization. Index-based insertion, replacement, and removal. Similar implementation of C# String.Format(..) to allow for terse index-based string interpolation without needing to use a literal with '$var' at the time of interpolation.

terminal added 3 commits July 20, 2014 17:04
String capitalization, as well as index-based insertion, replacement,
and removal.
Allows for terse, index-based string to act as mustache-esque templates
for interpolation. sprintf() does not satisfy this requirement.
@azenla
Copy link
Contributor

azenla commented Aug 2, 2014

LGTM

* If the [input] is longer than [original], the returned string will
* be longer than [original].
*/
String replaceAt(int index, String input, String original, {bool overwrite : false}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be more flexible as replace(String s, int index, String replacement, {int length}) where length defaults to replacement.length.

replace('foo', 3, 'bar') => 'foobar'
replace('foo', 0, 'bar') => 'bar'
replace('foo', 0, 'bar', length: 0) => 'barfoo'
replace('foo', 1, 'bar', length: 2) => 'fbar'

insert and remove would be sugar for calls to replace

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was pondering something along those lines.

@justinfagnani
Copy link
Contributor

Adding some more comments, but I forgot to ask earlier if you signed the Google CLA? https://developers.google.com/open-source/cla/individual

@ghost
Copy link
Author

ghost commented Aug 7, 2014

I haven't, for personal information privacy concerns (name/number, etc). If there's any way I can avoid that I'd be happy to do so.

@azenla
Copy link
Contributor

azenla commented Aug 7, 2014

@term1nal You can't avoid it. If it's really that big of a deal, maybe I could do it on your behalf?

I have signed the CLA.

@ghost
Copy link
Author

ghost commented Aug 7, 2014

Fine by me. I just need to get some spare time to make the necessary changes. I had an idea on how to do the interpolation without all of the calls to the regex matcher. (Rune by rune as suggested). Might be a bit ugly, but if it's significantly faster then ohwell.

@justinfagnani
Copy link
Contributor

Yeah, sorry, since this project is Google copyright, there's nothing I can do to exempt you from the CLA. It's all lawyerly stuff that I don't fully understand.

@azenla
Copy link
Contributor

azenla commented Aug 7, 2014

@justinfagnani Do you know if I were to re-do a PR from a fork of his branch, if that would be fine to use my CLA? Or does it HAVE to be him?

@ghost
Copy link
Author

ghost commented Aug 7, 2014

The lawyery peoples need to add in a clause or waiver for anonymous contributions and waivng rights. I have no attachment to the code I contribute other than wanting it to remain free. It's not worth dropping my docs to the internet and forego my right to privacy. I'll just give my commit over to kaendfinger after I'm doing doing the necessary tweaks that were mentioned, he's a good chap.

@justinfagnani
Copy link
Contributor

@kaendfinger I'm not at all sure. Let me check.

@term1nal The information we collect for the CLA is not public, it just sits in a document in case the lawyers need it. There might be a way you could sign and tell me out of band your name. I still understand if you don't want to sign though.

Removed formatStringList to add later after performance concerns are
researched further. Rewrote replacement to have replace be the base
function with remove and insert being syntactical sugar for calls to
replace.
@ghost
Copy link
Author

ghost commented Aug 25, 2014

I've rewritten the replacement functions and added the others as syntactical sugar as suggested. Removed formatStringList for now to figure out the performance concerns, as well as add other features. Will recommit that later on it's own.


`capitalize('this was a triumph!') => 'This Was A Triumph!'`

`replace` allows you to replace a porton of a string starting from a specified index.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/porton/portion/ or perhaps:
replace performs a substring replacement starting at the specified index.

});
});

group('replace', () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add tests for:

  • startIndex < 0: throws
  • startIndex == original.length: returns replacement
  • startIndex > original.length: throws
  • overwrite < 0: throws
  • overwrite == 0: behaves as an insert
  • overwrite > original.length - startIndex: replaces everything after startIndex

@cbracken
Copy link
Member

Missed the conversation about the CLA above. Can we get a resolution on how you want to proceed with that? I think the options are pretty much submit a CLA or close the PR and if someone else wants to get these in they could open a new one.

Justin, were you able to get any info on whether someone else could submit the code as-is or whether it would need to be a rewrite?

@justinfagnani
Copy link
Contributor

Uh... let's hold off on any more changes or comments on the code in this PR until we get the CLS issue resolved.

I wouldn't think that simply having someone else resubmit the PR solves anything, but I'd have to check with lawyer types for that, since it's certainly out of the normal path that we have guidance for. Unfortunately, checking in on corner cases of our policy and legal matters, while required for something like this, eats up time on our end. I think that the best approach here might be to file feature requests for each API addition and let the core team, or those who've signed the CLA reimplement from scratch. That might be quicker as waiting for word from our open source team which will probably be "no" anyway.

@cbracken
Copy link
Member

cbracken commented Sep 9, 2014

Closing since no update in two weeks. Unfortunately without a CLA, we can't proceed further on this.

@cbracken cbracken closed this Sep 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants