[Proposal] String.remove(subject, pattern)

186 views
Skip to first unread message

Alberto Almagro

unread,
Aug 25, 2017, 11:55:09 AM8/25/17
to elixir-lang-core
Hello,

I would like to add String.remove/2 with attributes (subject, pattern) to be able to remove patterns from Strings. Now when I want to remove a pattern from a String I have to replace it with an empty string like for example String.replace(string, " ", ""). While this works, in my opinion it doesn't give the code the meaning I want. Calling String.remove(string, " ") would much better reveal my intention of removing a pattern instead of replacing it.

If you agree with this, I would like to make and submit a PR adding this feature. If you also want to add some options to it, please tell me the ones you think that may be useful.

Thanks in advance for the time you spend reviewing my proposal,
Alberto

Alberto Almagro

unread,
Sep 3, 2017, 6:26:57 AM9/3/17
to elixir-lang-core
Although in the example I put an empty string " " as pattern, I would like to clarify that the concept of the pattern would be the same as in String.replace/4,

What do you think?

Alberto Almagro

unread,
Sep 18, 2017, 3:16:41 AM9/18/17
to elixir-lang-core
This has been here almost for a month.... any thoughts guys?


El viernes, 25 de agosto de 2017, 17:55:09 (UTC+2), Alberto Almagro escribió:

OvermindDL1

unread,
Sep 18, 2017, 10:33:00 AM9/18/17
to elixir-lang-core
I'd recommend posting this on the forums, it should generate more discussion there and have more visibility.  Overall though Jose will look at it here when he gets time.  :-)

José Valim

unread,
Sep 18, 2017, 10:39:04 AM9/18/17
to elixir-l...@googlegroups.com
When I am not certain if a feature will be useful, I let the community step in. In this case, it seems there is not a lot of interest, which is probably a sign that we don't need the feature. In any case, thanks for the proposal Alberto Almagro.

Here is also the official place for feature proposals, so we should not redirect to the forum. :)



José Valim
Founder and 
Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/31d0bc53-9a16-4262-9533-8121e85ec89b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

OvermindDL1

unread,
Sep 18, 2017, 11:12:54 AM9/18/17
to elixir-lang-core
On Monday, September 18, 2017 at 8:39:04 AM UTC-6, José Valim wrote:
When I am not certain if a feature will be useful, I let the community step in. In this case, it seems there is not a lot of interest, which is probably a sign that we don't need the feature. In any case, thanks for the proposal Alberto Almagro.

Here is also the official place for feature proposals, so we should not redirect to the forum. :)

For official features, but considering the lack of discussion I was hinting at the forums so someone could make a library to add the functionality to query general interest before an official feature might be accepted.  :-) 

Alberto Almagro

unread,
Sep 18, 2017, 11:38:58 AM9/18/17
to elixir-lang-core
Thanks guys for stepping in!

José Valim, maybe people haven't yet stepped in because this proposal is no rocket science GenServer or the likes ;-) I definitely think it would contribute to make Elixir more beautiful. Don't you think it expresses much better the intention of the code if we were able to write String.remove instead of replacing with white spaces?

Thanks!


El lunes, 18 de septiembre de 2017, 16:39:04 (UTC+2), José Valim escribió:
When I am not certain if a feature will be useful, I let the community step in. In this case, it seems there is not a lot of interest, which is probably a sign that we don't need the feature. In any case, thanks for the proposal Alberto Almagro.

Here is also the official place for feature proposals, so we should not redirect to the forum. :)



José Valim
Founder and 
Director of R&D

On Mon, Sep 18, 2017 at 4:33 PM, OvermindDL1 <overm...@gmail.com> wrote:
I'd recommend posting this on the forums, it should generate more discussion there and have more visibility.  Overall though Jose will look at it here when he gets time.  :-)

On Monday, September 18, 2017 at 1:16:41 AM UTC-6, Alberto Almagro wrote:
This has been here almost for a month.... any thoughts guys?

El viernes, 25 de agosto de 2017, 17:55:09 (UTC+2), Alberto Almagro escribió:
Hello,

I would like to add String.remove/2 with attributes (subject, pattern) to be able to remove patterns from Strings. Now when I want to remove a pattern from a String I have to replace it with an empty string like for example String.replace(string, " ", ""). While this works, in my opinion it doesn't give the code the meaning I want. Calling String.remove(string, " ") would much better reveal my intention of removing a pattern instead of replacing it.

If you agree with this, I would like to make and submit a PR adding this feature. If you also want to add some options to it, please tell me the ones you think that may be useful.

Thanks in advance for the time you spend reviewing my proposal,
Alberto

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Allen Madsen

unread,
Sep 18, 2017, 1:53:14 PM9/18/17
to elixir-l...@googlegroups.com
Having watched the discussion on similar features, I'd say the criteria is something like:

1. Does it allow something that is otherwise not possible
2. Does it substantially reduce the amount of work required for a common use case

To me, this would best fit under 2, but doesn't substantially reduce the amount of work required.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e36abd5e-a4e6-4f60-934b-8b9e4dd7d61b%40googlegroups.com.

Tallak Tveide

unread,
Sep 18, 2017, 2:54:24 PM9/18/17
to elixir-lang-core
Hi. I think its a fine suggestion, and i agree that its more descriptiive than the alternatives. Even so, the amount of use it would see would perhaps not be so big that we could not equally well get by with using replace. Keeping the stdlib consise is a quite major issue, so I'd have to agree on not adding this. I never did this operation in any language as far as I can remember, even having done lots of text processing. That is probably a testament to my coding atyle also, but still

Alberto Almagro

unread,
Sep 18, 2017, 3:33:27 PM9/18/17
to elixir-lang-core
Good points, the feature itself won't be complex to add or maintain. I would like Elixir to be a language not only powerful with the machine, but also to be the most friendly as possible with the developer. For me that is the key point: how do we want the language to be in the future?

Kelvin Raffael Stinghen

unread,
Sep 18, 2017, 4:26:00 PM9/18/17
to elixir-l...@googlegroups.com
Well, since the reason of not accepting it yet is the lack of noise about it, just making some noise: I’m +1 for this feature. Maybe another name for the method, but I guess `String.remove/2` is good enough.

On 18 Sep 2017, at 16:33, Alberto Almagro <alberto...@gmail.com> wrote:

Good points, the feature itself won't be complex to add or maintain. I would like Elixir to be a language not only powerful with the machine, but also to be the most friendly as possible with the developer. For me that is the key point: how do we want the language to be in the future?

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Alberto Almagro

unread,
Sep 18, 2017, 4:52:52 PM9/18/17
to elixir-lang-core
Kelvin Raffael Stinghen <3

In Elixir we can do lots of operations by traversing lists, however we still add functions to the language to make our lives easier and to make our code easier to read. I think this is the way to go and that this feature contributes to continue in this direction.

Alberto Almagro

unread,
Oct 4, 2017, 12:18:39 PM10/4/17
to elixir-lang-core
Hi! Does someone have more thoughts on this? Thanks!


El viernes, 25 de agosto de 2017, 17:55:09 (UTC+2), Alberto Almagro escribió:

Alberto Almagro

unread,
Oct 17, 2017, 5:54:24 PM10/17/17
to elixir-lang-core
I have implemented a first version of it. What do you think? https://github.com/elixir-lang/elixir/commit/f8ce1c4f066fef26670a9142d347ac6cf99db93a

Thanks in advance,
Alberto


El viernes, 25 de agosto de 2017, 17:55:09 (UTC+2), Alberto Almagro escribió:

José Valim

unread,
Oct 17, 2017, 6:06:31 PM10/17/17
to elixir-l...@googlegroups.com
Hi Alberto, please note we won't be accepting this feature as it doesn't offer much on top of replace. Thanks!





José Valim
Founder and 
Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5883f963-4bdd-40ac-b3d4-cb9522dbb8cd%40googlegroups.com.

Alberto Almagro

unread,
Oct 17, 2017, 6:15:42 PM10/17/17
to elixir-lang-core
What a pity José. I will keep it anyway, in case you decide to include it in the future just tell me.


El miércoles, 18 de octubre de 2017, 0:06:31 (UTC+2), José Valim escribió:
Hi Alberto, please note we won't be accepting this feature as it doesn't offer much on top of replace. Thanks!





José Valim
Founder and 
Director of R&D

On Tue, Oct 17, 2017 at 11:54 PM, Alberto Almagro <alberto...@gmail.com> wrote:
I have implemented a first version of it. What do you think? https://github.com/elixir-lang/elixir/commit/f8ce1c4f066fef26670a9142d347ac6cf99db93a

Thanks in advance,
Alberto


El viernes, 25 de agosto de 2017, 17:55:09 (UTC+2), Alberto Almagro escribió:
Hello,

I would like to add String.remove/2 with attributes (subject, pattern) to be able to remove patterns from Strings. Now when I want to remove a pattern from a String I have to replace it with an empty string like for example String.replace(string, " ", ""). While this works, in my opinion it doesn't give the code the meaning I want. Calling String.remove(string, " ") would much better reveal my intention of removing a pattern instead of replacing it.

If you agree with this, I would like to make and submit a PR adding this feature. If you also want to add some options to it, please tell me the ones you think that may be useful.

Thanks in advance for the time you spend reviewing my proposal,
Alberto

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages