Core/Async and Bytes

30 views
Skip to first unread message

Malcolm Matalka

unread,
May 7, 2015, 5:12:57 PM5/7/15
to ocaml...@googlegroups.com
Hello, I'm trying to write some File I/O code that uses Bytes, and I'm
just unsure of where Core is in the transition. Specifically I am
trying to avoid copying. Is it safe to switch all mutable uses of
String.t to Byte.t and things will Just Work?

Thanks,
/Malcolm

Ben Millwood

unread,
May 8, 2015, 5:05:29 AM5/8/15
to ocaml...@googlegroups.com
Although we plan to turn safe strings on one day, I don't think there's yet been much in the way of progress on that front. As such, compiling a program that uses core with -safe-string is probably not a great idea, and so it doesn't matter from a correctness perspective whether you use string or bytes.


--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Malcolm Matalka

unread,
May 8, 2015, 5:31:47 AM5/8/15
to ocaml...@googlegroups.com

What about being future proof?  Should I prefer Bytes now where I have string so I don't have to change much if anything when the fateful day comes?

Ben Millwood

unread,
May 8, 2015, 5:52:38 AM5/8/15
to ocaml...@googlegroups.com
I don't think you'll be able to insulate yourself against future design decisions. When the switch is eventually made, it could potentially involve API changes to reflect different design constraints, so merely replacing some string types with bytes doesn't seem that likely to save you work. Moreover, there's no timeline for the switch, so I don't imagine it being too unlikely you're struck by some inspiration that causes you to rewrite your entire codebase in between now and then :)

That said, using bytes where it is your intention to mutate the buffer can be good practice from the standpoint of having your code say what it means.
Reply all
Reply to author
Forward
0 new messages