Re: Should String.prototype.split accept variable arguments optionally?

2013-10-24 Thread Angus Croll
with the separate arguments solution the 'limit' argument is unusable with the array solution you have a punctuation nightmare the required regex seems easier in comparison On Wed, Oct 16, 2013 at 5:54 AM, Benjamin (Inglor) Gruenbaum < ing...@gmail.com> wrote: > Splitting by one value or anothe

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Benjamin (Inglor) Gruenbaum
On Wed, Oct 16, 2013 at 11:46 PM, Rick Waldron wrote: > > What about the version with the overload accepting an Array instead? It seems more backwards compatible than the varargs version. I meant the version accepting an array `.split([a,b,c])` rather than `.split(a,b,c)` but the 12 years and t

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Rick Waldron
On Wed, Oct 16, 2013 at 4:25 PM, Benjamin (Inglor) Gruenbaum < ing...@gmail.com> wrote: > On Wed, Oct 16, 2013 at 9:03 PM, Andrea Giammarchi < > andrea.giammar...@gmail.com> wrote: > > How could change 12+ years of legacy be considered inexpensive ? > > This proposal does not break anything, the o

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
also, to reply your question "Are you against changes like `.contains` or `.startsWith` too?" Absolutely not, and these are new methods indeed. Perfectly in line with what you wrote: > Why have `str.contains` if you can just do `~str.indexOf`. Why have `.startsWith`, or `.indexOf` on arrays? You

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
It does break in many ways as also Brendan said. `''.split(what, ever)` would break plus `"some1,2thing".split([1,2])` you have no idea what you could find in legacy code ... so whatever a 12+ years old legacy does shold keep doing like that and if you really want to put your array in there fo

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Benjamin (Inglor) Gruenbaum
On Wed, Oct 16, 2013 at 9:03 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > How could change 12+ years of legacy be considered inexpensive ? This proposal does not break anything, the only thing that will/might work differently is people passing an array to .split right now and expe

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Brendan Eich
It's hard to add extra optional arguments to a long-standing built-in. People write code that passes an extra arg that has been ignored till the change; browsers that try shipping the new version then break that content, user blames browser (rightly so) but also the page, sometimes (not right).

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
typo: Non "highly trained professionals" should *do* simple things On Wed, Oct 16, 2013 at 11:03 AM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > How could change 12+ years of legacy be considered inexpensive ? > > Non "highly trained professionals" should be simple things or try to

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
How could change 12+ years of legacy be considered inexpensive ? Non "highly trained professionals" should be simple things or try to learn something new that won't hurt, that's why Stack Overflow exists in first place, to ask for help or explanations about things. This request sounds to me like

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Benjamin (Inglor) Gruenbaum
On Wed, Oct 16, 2013 at 8:18 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > >also, this is the same: `myString.split(/[ -/+]/)` Yes, that's true, not sure how that works for multi character delimiters. > maybe it's better to explain those users that knowing RegExp might bring bene

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
also, this is the same: `myString.split(/[ -/+]/)` maybe it's better to explain those users that knowing RegExp might bring benefits for their purpose (coding) ? On Wed, Oct 16, 2013 at 10:14 AM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > I stopped here > > > On Wed, Oct 16, 201

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Andrea Giammarchi
I stopped here On Wed, Oct 16, 2013 at 5:54 AM, Benjamin (Inglor) Gruenbaum < ing...@gmail.com> wrote: > > ``` > myString.split(/ |-|\/|\+/g); // this is no fun to read > > myString.split(" ","-","/","+"); // this is easier > myString.split([" ","-","/","+"]); // this is also easier.

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Benjamin (Inglor) Gruenbaum
On Wed, Oct 16, 2013 at 7:15 PM, Rick Waldron wrote: > >This is subjective, as I have no trouble reading and understanding what this means and is expected to do (also subjective). Of course, this is another way to do it that does not require knowing regular expressions. I have no doubt that bei

Re: Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Rick Waldron
On Wed, Oct 16, 2013 at 8:54 AM, Benjamin (Inglor) Gruenbaum < ing...@gmail.com> wrote: > Splitting by one value or another seems to be a pretty common use case if > Stack Overflow questions and personal experience are an indication. For > example "-" and " " and "/". > > Currently, the solution i

Should String.prototype.split accept variable arguments optionally?

2013-10-16 Thread Benjamin (Inglor) Gruenbaum
Splitting by one value or another seems to be a pretty common use case if Stack Overflow questions and personal experience are an indication. For example "-" and " " and "/". Currently, the solution is to pass a regular expression to String.prototype.split . However, it would be nice to be able t