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

split function doesn't work #329

Closed
p6rt opened this issue Sep 19, 2008 · 5 comments
Closed

split function doesn't work #329

p6rt opened this issue Sep 19, 2008 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 19, 2008

Migrated from rt.perl.org#59064 (status was 'resolved')

Searchable as RT59064$

@p6rt
Copy link
Author

p6rt commented Sep 19, 2008

From @pmichaud

On Sat, Sep 20, 2008 at 12​:33​:27AM +1100, Илья wrote​:

For example​:
split /''/, $string
splits between characters.

this do not work properly in Rakudo​:
say (split /''/, "foo").perl; # ["foo"]

Currently the split function (note function, not method) is in
src/classes/Str.pir, and it appears to be coercing its arguments
into strings.

This function needs to be moved to src/builtins/any-str.pir,
and updated to accept pmc arguments. Perhaps something like​:

  .namespace ['']
  .sub 'split' :multi(_, _)
  .param pmc sep
  .param pmc target
  .return target.'split'(sep)
  .end

Pm

@p6rt
Copy link
Author

p6rt commented Sep 20, 2008

From @moritz

On Fri Sep 19 06​:49​:37 2008, pmichaud wrote​:

On Sat, Sep 20, 2008 at 12​:33​:27AM +1100, Илья wrote​:

For example​:
split /''/, $string
splits between characters.

this do not work properly in Rakudo​:
say (split /''/, "foo").perl; # ["foo"]

Currently the split function (note function, not method) is in
src/classes/Str.pir, and it appears to be coercing its arguments
into strings.

This function needs to be moved to src/builtins/any-str.pir,
and updated to accept pmc arguments. Perhaps something like​:

\.namespace \[''\]
\.sub 'split' :multi\(\_, \_\)
    \.param pmc sep
    \.param pmc target
    \.return target\.'split'\(sep\)
\.end

Pm

It has been moved, but it doesn't solve all problems. To be more specific​:

split("4", "345").perl.say
["3", "5"]
split(4, "345").perl.say
["3", "5"]
split(4, 345).perl.say
No applicable methods.
split(/b/, 'abc').perl.say
["a", "c"]

So it seems the only thing left to do is make split with non-regex and
non-string delimiter work on non-strings.

(Other TODO items are the behaviour with regexes that produce zero-width
matches, but that's for another ticket, I think).

Moritz

@p6rt
Copy link
Author

p6rt commented Sep 20, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 22, 2008

From @moritz

Fixed in r31333.

@p6rt
Copy link
Author

p6rt commented Sep 22, 2008

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 22, 2008
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant