> On Jun 27, 2024, at 2:22 AM, Stephen Reay <php-li...@koalephant.com> wrote:
>
> I do appreciate that strtok has a kind of bizarre signature/use pattern and 
> potential for confusion due to how subsequent calls work, but to me that 
> sounds like a better result for uses that need the repeated call 
> functionality, would be to introduce a builtin `StringTokenizer` class that 
> wraps the underlying strtok_r C call and uses internal state to keep track of 
> the string being tokenized.

strtok is weird, but it’s not actually dangerous. An OO wrapper doesn’t sound 
worth it unless it comes with compelling extra features or at least a reusable 
abstraction in the form of a concrete `StrTokTokenizer` (or hopefully a less 
ugly name) implementing a StringTokenizer interface.

Personally I say let strtok be and just admit in the documentation that it’s 
weird because C.

[Resent to the list. Sorry for any previously cc'd dups, macOS Mail keeps 
guessing the wrong sender address.]
—c (weird just because)

Reply via email to