Skip to content
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

Str.string_before doesn't follow spec #3340

Closed
vicuna opened this issue May 6, 2002 · 1 comment
Closed

Str.string_before doesn't follow spec #3340

vicuna opened this issue May 6, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented May 6, 2002

Original bug ID: 1145
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: mattias waldau
Version: 3.04
OS: rh72
Submission from: h175n2fls34o849.telia.com (217.208.235.175)

Str.string_before "f" 2 returns exception Invalid_argument.

However, according to the spec it should return "all chars that precede position
n".

In this case, the answer should be "f" since "f" are all chars that precede 2.

(In general, I think this is a general design flaw in the string-functions of
O'Caml, they should rarely return exception, just shorter strings. If
a programmer wants the behavior of string_before, he should check the
length himself. Strings are not arrays.

The current implementation makes it difficult just to check if a string
starts with "%%")

@vicuna
Copy link
Author

vicuna commented Jun 11, 2002

Comment author: administrator

Behavior is as intended.

@vicuna vicuna closed this as completed Jun 11, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant