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

String.blit should be [@@ocaml.deprecated] #6541

Closed
vicuna opened this issue Sep 3, 2014 · 6 comments
Closed

String.blit should be [@@ocaml.deprecated] #6541

vicuna opened this issue Sep 3, 2014 · 6 comments
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 3, 2014

Original bug ID: 6541
Reporter: jpdeplaix
Status: closed (set by @xavierleroy on 2016-12-07T10:47:20Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.02.0+beta1 / +rc1
Target version: 4.02.2+dev / +rc1
Category: standard library

Bug description

As it should be replaced by Bytes.blit_string, String.blit should be flagged as deprecated.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2014

Comment author: jpdeplaix

And same thing for String.unsafe_blit of course.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2014

Comment author: @gasche

String.set is deprecated because there is no string that is being set with its new -safe-string type:
bytes -> int -> char -> unit
so having this function in the String module doesn't make much sense anymore.

On the contrary,
String.blit : string -> int -> bytes -> int -> int -> unit
still makes sense: there is indeed a string being blitted in the arguments -- and if you think of it in terms of the bytes into which we blit, it is also called Bytes.blit_string.

I don't think this function need to be deprecated.

@vicuna
Copy link
Author

vicuna commented Sep 4, 2014

Comment author: jpdeplaix

Why is String.fill deprecated then ?
It doesn't seems different from String.fill and deprecating it allows to switch more easily in -safe-string mode by marking this as possibly wrong considering the new use of strings.

@vicuna
Copy link
Author

vicuna commented Sep 4, 2014

Comment author: @gasche

The argument of fill is a bytes, not a string, so it doesn't make much sense anymore in the String module. On the contrary, String.blit has a string argument. There is nothing wrong about using String.blit with -safe-string if you want.

@vicuna
Copy link
Author

vicuna commented Sep 5, 2014

Comment author: jpdeplaix

But String.fill has also a bytes argument. The point is: it should be deprecated as it was before used to modify strings.

@vicuna
Copy link
Author

vicuna commented Sep 10, 2014

Comment author: @damiendoligez

The point is that String.blit (unlike String.fill) does have a string argument, so it arguably belongs in the String module.

The idea of the warnings is not to catch strings that should be bytes (the typechecker does that perfectly), it's more to gently remind the programmers that they should be converting to Bytes. So it's not a big deal if some functions are not marked deprecated even though their type has changed.

@vicuna vicuna closed this as completed Dec 7, 2016
@vicuna vicuna added the stdlib label Mar 14, 2019
@vicuna vicuna added this to the 4.02.2 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant