{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/626","repository_url":"https://api.github.com/repos/ocaml/ocaml","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/626/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/626/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/626/events","html_url":"https://github.com/ocaml/ocaml/pull/626","id":161160302,"number":626,"title":"String.split","user":{"login":"alainfrisch","id":3305274,"avatar_url":"https://avatars.githubusercontent.com/u/3305274?v=3","gravatar_id":"","url":"https://api.github.com/users/alainfrisch","html_url":"https://github.com/alainfrisch","followers_url":"https://api.github.com/users/alainfrisch/followers","following_url":"https://api.github.com/users/alainfrisch/following{/other_user}","gists_url":"https://api.github.com/users/alainfrisch/gists{/gist_id}","starred_url":"https://api.github.com/users/alainfrisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alainfrisch/subscriptions","organizations_url":"https://api.github.com/users/alainfrisch/orgs","repos_url":"https://api.github.com/users/alainfrisch/repos","events_url":"https://api.github.com/users/alainfrisch/events{/privacy}","received_events_url":"https://api.github.com/users/alainfrisch/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ocaml/ocaml/labels/stdlib","name":"stdlib","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":66,"created_at":"2016-06-20T10:06:34Z","updated_at":"2016-07-11T15:22:31Z","closed_at":"2016-07-09T21:42:45Z","pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/626","html_url":"https://github.com/ocaml/ocaml/pull/626","diff_url":"https://github.com/ocaml/ocaml/pull/626.diff","patch_url":"https://github.com/ocaml/ocaml/pull/626.patch"},"body":"Not wanting to reopen old wounds (#10), but `String.split` would be a really useful addition to the stdlib.\r\n\r\nI propose to add a form where the separator is a single character.  Compared to a version with a string delimiter, the advantages of this simpler version are:\r\n\r\n- A self-explanatory type: no need to introduce labelled arguments to disambiguate between two string arguments.\r\n\r\n- A total function that never fails, no special support for the empty separator.\r\n\r\n- Higher-level specification: no need to specify the matching algorithm to specify the behavior when the separator overlaps with itself (nor to introduce two variants for left-to-right and right-to-left traversal).\r\n\r\nIt's worth noting that both JaneStreet Core and ExtLib/Batteries expose a similar feature. ExtLib's [String.nsplit] has a string separator, but I could not find a single use of it with a long separator ( https://github.com/search?l=ocaml&p=4&q=%22String.nsplit%22&ref=searchresults&type=Code&utf8=%E2%9C%93 ).\r\n\r\nAlso, a similar function is implemented multiple times in the compiler code base:\r\n\r\n - Misc.Stdlib.String.split.\r\n - Misc.split.\r\n - Dumpobj.read_primitive_table\r\n - Dll.split\r\n - Primitives.split_string (in debugger), although this seems to be dead code\r\n\r\nNot talking about ocamldoc's `split_string` interesting implementation (it supports multiple character separator, but this shows what people can actually write...).\r\n\r\nSee also http://rosettacode.org/wiki/Tokenize_a_string#OCaml : several inefficient and uselessly complex implementations.\r\n"},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/231767839","html_url":"https://github.com/ocaml/ocaml/pull/626#issuecomment-231767839","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/626","id":231767839,"user":{"login":"lefessan","id":514957,"avatar_url":"https://avatars.githubusercontent.com/u/514957?v=3","gravatar_id":"","url":"https://api.github.com/users/lefessan","html_url":"https://github.com/lefessan","followers_url":"https://api.github.com/users/lefessan/followers","following_url":"https://api.github.com/users/lefessan/following{/other_user}","gists_url":"https://api.github.com/users/lefessan/gists{/gist_id}","starred_url":"https://api.github.com/users/lefessan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lefessan/subscriptions","organizations_url":"https://api.github.com/users/lefessan/orgs","repos_url":"https://api.github.com/users/lefessan/repos","events_url":"https://api.github.com/users/lefessan/events{/privacy}","received_events_url":"https://api.github.com/users/lefessan/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T15:22:31Z","updated_at":"2016-07-11T15:22:31Z","body":"I am personally for `String.split`, and I really dislike `String.split_on_char`. Why not `String.split_on_a_separator_that_is_a_char_to_obtain_a_list_of_strings` ? The stdlib is supposed to provide the shortest names for the most common functions, we shouldn't care about compatibility with Batteries, especially when Batteries has been warned for years that it shouldn't include `String` or advertize itself as a strict superset of the stdlib (something that it should never have promised to its users), because doing so is known to create incompatibilities with every new version of OCaml."}}
{"actor":{"display_login":"lefessan"}}