The bytevector-copy
function always expects three arguments, instead of allowing the last two to be optional. I'm using bytevectors a lot in an application, and it is convenient to pull sections out of them using the 2-argument version, so I happened to notice this. Unless I've completely misunderstood something, then it works different than the documentation.
From LispPad Reference 1.7:
Returns a newly allocated bytevector containing the bytes in bytevector between start and end. If end is not provided, it is assumed to be the length of bytevector. If start is not provided, it is assumed to be 0.
However, in LispPad 1.72 on macOS, both the 1-argument and 2-argument versions give range error:
➤ a
#u8(1 2 3 4 5)
➤ (bytevector-copy a)
⚠️ 〚range error〛 expected argument 2 of function bytevector-copy to be an integer value within the range [0, 4]; is 5 instead
└── (bytevector-copy …) « ( …)
➤ (bytevector-copy a 1)
⚠️ 〚range error〛 expected argument 3 of function bytevector-copy to be an integer value within the range [1, 5]; is 0 instead
└── (bytevector-copy …) « ( …)
➤ (bytevector-copy a 1 4)
#u8(2 3 4)
I looked at the source code, and I'm not sure I know what is happening to make a pull request, but maybe this turns out to be a quick fix for you.
The LispKit documentation agrees with R7RS, but SRFI 66 doesn't seem to have byte-vector-copy with up to three arguments.
Possible workaround: compute desired length and index, then use the 3-argument version.