CleanShot-2023-11-22-at-18.33.27.png
https://www.roc-lang.org/builtins/Num#bytesToU16
There's no comment explaining these and its not super clear by the name + signature what exactly these do. My assumption is they probably decode a number from the list, but firstly its unclear what the second parameter is (number of bytes that should contribute to the number maybe? seems like its an offset in the list where the number begins), and secondly if this is what this does then in what byte order?
CleanShot-2023-11-22-at-18.41.39.png
or I guess they actually don't do anything.. lol
Not implemented in the dev backend apparently (that is what the repl uses)
So all of these functions should have their api changed, they were created before the days of seamless slices.
They should just take a List U8
and probably also a tag union related to endianess so [BigEndian, LittleEndian]
.
I see, that would be nice yeah!
The Nat
that they currently take is an offset into the list, which is unnecessary at this point.
So Should probably become List U8, [BigEndian, LittleEndian] -> U64
Just to clarify: Your example code works fine in compiled programs and in the web REPL, just not in the command line REPL. The goal is for all three to eventually be equivalent, but we're not there yet.
Here's a screenshot from the web REPL
Screenshot-2023-11-23-at-07.51.41.png
Thanks! Good to know about trying things in the web REPL too.
Last updated: Jul 06 2025 at 12:14 UTC