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

Add a few utility functions in Misc #2284

Merged
merged 2 commits into from Mar 15, 2019

Conversation

@mshinwell
Copy link
Contributor

commented Mar 5, 2019

This GPR provides a few straightforward functions in Misc that are required by the forthcoming work on symbol types. I don't think there is value in breaking this patch down into smaller pieces, given current time constraints.

Copy link
Contributor

left a comment

The Option module exists in the stdlib. Shouldn't you try using it, instead of Misc.Stdlib.Option?
Also, the one in Misc I believe duplicates some of the functions of the one in the stdlib. Perhaps it would be better to look into cleaning Misc.Stdlib instead of growing it even more.

@@ -214,6 +227,9 @@ module Stdlib = struct
i = len || (f t.[i] && loop (i + 1))
in
loop 0

let print ppf t =
Format.pp_print_string ppf t

This comment has been minimized.

Copy link
@trefis

trefis Mar 5, 2019

Contributor

Pffff.

utils/misc.ml Outdated Show resolved Hide resolved
@mshinwell

This comment has been minimized.

Copy link
Contributor Author

commented Mar 5, 2019

Indeed, I think these probably predate the support in the Stdlib for Option that I had forgotten about. I will see how much we can remove from Misc.

@mshinwell mshinwell force-pushed the mshinwell:misc_functions branch from a9849d4 to ded3098 Mar 6, 2019
@mshinwell

This comment has been minimized.

Copy link
Contributor Author

commented Mar 6, 2019

@trefis Please review again. I have removed the functions from Misc.Stdlib.Option that are now in the stdlib.

Copy link
Contributor

left a comment

The cleanup of Misc.Stdlib.Option is nice!
Adding a printer in there seems reasonable.

The addition of Misc.protect_writing_to_file is also fine.

I would remove the alias to Format.pp_print_string from Misc.Stdlib.String though.

@trefis

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2019

Also, I tend to agree with Alain: I'm not sure there is much value in a changelog entry for that PR.

@mshinwell

This comment has been minimized.

Copy link
Contributor Author

commented Mar 6, 2019

The print function in String was put there for a reason: I'd like modules to have a uniform interface, which includes printing for all data structures.

@Drup

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2019

The print function in String was put there for a reason: I'd like modules to have a uniform interface, which includes printing for all data structures.

I agree with that on principle, the issue is dependency order of stdlib modules.

At some point, we need to have a serious though about the exact dependency orders we want for the stdlib modules. I remember @dbuenzli being pretty burned by that for the UChar module (iirc).

That being said, the convention for pretty printing functions is pp, not print. :)

@mshinwell

This comment has been minimized.

Copy link
Contributor Author

commented Mar 6, 2019

@Drup Well, we need to have a serious discussion as to how printing can be added to the data structure modules in the stdlib. Let's do that elsewhere though...

@dbuenzli

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2019

I remember @dbuenzli being pretty burned by that for the UChar module (iirc).

Just for the ref this was https://caml.inria.fr/mantis/view.php?id=7500

@trefis

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2019

I agree with that on principle, the issue is dependency order of stdlib modules.

We're not talking about the stdlib here, only of Misc.Stdlib.

Since people think it's fine I'll retract my comment and approve.

@trefis
trefis approved these changes Mar 13, 2019
Copy link
Contributor

left a comment

Feel free to merge once you've rebased.

@mshinwell mshinwell force-pushed the mshinwell:misc_functions branch from ded3098 to 4b60703 Mar 13, 2019
@mshinwell mshinwell merged commit e141d9e into ocaml:trunk Mar 15, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.