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

Pour go's strings package into a "str:" module #576

Closed
xiaq opened this issue Jan 22, 2018 · 12 comments
Closed

Pour go's strings package into a "str:" module #576

xiaq opened this issue Jan 22, 2018 · 12 comments

Comments

@xiaq
Copy link
Member

@xiaq xiaq commented Jan 22, 2018

In the same spirit of pouring Go's regexp package into the re: module, let's do the same to the excellent strings package.

@occivink
Copy link

@occivink occivink commented Jan 22, 2018

Would joins and splits be moved to that module?

xiaq added a commit that referenced this issue Jan 26, 2018
This addresses #576.
@xiaq
Copy link
Member Author

@xiaq xiaq commented Jan 26, 2018

@occivink Yes, and they will be renamed str:join and str:split.

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 10, 2020

Which, if any, elvish commands should automatically coerce their values to strings if they expect that argument to be a string? I'm asking this in the context of PR #928 and PR #934. What does it mean to pass a (float64 ...) as an argument to a command that requires a string. Should elvish automatically convert the value or should we require the user to do a (to-string $value)? Given the recent introduction of a float64 data type is it reasonable to require the user to use to-string when passing the value of a variable to a command that requires a string?

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 11, 2020

@xiaq Should builtins like has-prefix be marked as deprecated and the reader told to use str:has-prefix? Or should the documentation be left as is but with a note that the command is simply an alias for the equivalent str: command and the str: form is preferred?

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 11, 2020

Also, if has-prefix is simply an alias for str:has-prefix shouldn't the former defer to the latter rather than reinvent the wheel? That reinvention, or independent implementation, leading to possible incompatible behavior?

@zzamboni
Copy link
Contributor

@zzamboni zzamboni commented Mar 11, 2020

@xiaq has described somewhere (but I can't find it at the moment) his idea for deprecating features over a two-release cycle, I think this is the way this could be handled.

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 12, 2020

@zzamboni Understood, vis-a-vis the deprecation model. In fact, that's the model I normally use for this situation. So I've created a PR to formally deprecate the has-prefix and has-suffix builtins and start the clock ticking. Which doesn't necessarily mean they will actually be removed prior to the 0.16 release but it does put people on notice that they need to start using the commands in the str: rather than the builtin: name space. Note that str:has-prefix and str:has-suffix was introduced by commit 9d34212 way back on 2018-01-26. Since the str: name space seems unlikely to go away it's time to start simplifying the builtin: name space by removing such redundancies.

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented May 13, 2020

@xiaq, It seems like this can be closed. While we haven't poured the entirety of Go's string package into the str module we've got all the most useful functions. Other functions can be handled on a case-by-case basis as people find a need a particular function.

@xiaq
Copy link
Member Author

@xiaq xiaq commented May 17, 2020

Sounds good, closing.

@xiaq xiaq closed this May 17, 2020
@tfga
Copy link

@tfga tfga commented May 21, 2020

The docs already say

joins is deprecated; use str:join instead.

but that's not the reality of the latest release:

$ elvish --version
v0.13.1

$ elvish

$ use str

$ resolve joins
▶ '$joins~'

$ resolve str:join
▶ '(external str:join)'

It would be nice if there was a way to keep these things in sync.
Maybe instead of having just one URL for the docs, we could have one for each version? 🤔

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented May 21, 2020

@tfga, Good point about the online documentation not making it clear that you're reading the docs for the "master" branch, not the most recent released version. I'll open an issue about that. But note that you'll get the same result using elvish built from the "master" branch because you didn't first do use str.

@tfga
Copy link

@tfga tfga commented May 22, 2020

@krader1961 Thanks! 👍

you didn't first do use str

Fixed in my comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants