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
New functions for bytes/strings #6500
Comments
Comment author: @alainfrisch Commit 15029 on 4.02 (15030 on trunk) adds String.init, Bytes.init, Labels couterparts, Stream.of_byte. |
Comment author: @gasche The attached patch implements String.mapi, and Bytes.mapi in passing. If that is all right, I'd like to commit it eventually. I also specified the iteration order of init/map/mapi: in my experience users rely on it anyway, so we cannot change it, and it's better to not worry and just document it from the start. I think the functions you listed are important and we should provide them to have a smooth transition. I can help with the implementation -- in any case I plan to document Bytes.unsafe_to_string and Bytes.unsafe_of_string, and try to minimize use of the latter. |
Comment author: @alainfrisch Gabriel: please commit mapi (also updating StringLabels/BytesLabels). Also, the type bytes is really just an optimized implementation of "char array", and it thus makes sense to have the Bytes module implements all relevant operations from Array. The ones currently missing: val to_list: bytes -> char list We should also consider renaming Bytes.cat to Bytes.append. Bytes.concat is a little bit problematic, since Array.concat also exists, but without the delimiter, and we want to keep the same name as String. |
Comment author: @damiendoligez Most of these function types don't make sense to me: a single "bytes" argument is pretty useless, you should almost always take three arguments: bytes, offset, length. |
Comment author: kaustuv Also worth adding: Format.pp_print_bytes. This should then also be a registered printer in the toplevel if it is invoked with -safe-string. |
The standard library has |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Still an issue. |
…f_byte. git-svn-id: http://caml.inria.fr/svn/ocaml/version/4.02@15029 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
No more string copy, byt OCaml stdlib for Scanf.Scanning is lacking a from_bytes :-( (see ocaml/ocaml#6500)
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 6500
Reporter: @alainfrisch
Status: feedback (set by @damiendoligez on 2014-08-20T08:24:44Z)
Resolution: open
Priority: normal
Severity: feature
Category: standard library
Tags: patch
Monitored by: braibant @whitequark
Bug description
Some useful functions to create string (esp. String.init, which avoids the need to go through a bytes than copy it):
Some more useful functions to avoid copying between bytes and string, at least explicitly (this is much lower priority, I'd say):
(There are a few more in
Scanf
,Printf
.)File attachments
The text was updated successfully, but these errors were encountered: