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

Document Lwt_io.printf flushing behavior #544

Merged
merged 5 commits into from
Feb 13, 2018
Merged

Conversation

smithjessk
Copy link
Contributor

As described in #455.

Copy link
Collaborator

@aantron aantron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I left a couple notes :)

val fprintf : output_channel -> ('a, unit, string, unit Lwt.t) format4 -> 'a
(* %! does nothing here. To flush the channel, use Lwt_io.(flush channel) *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, just in case: to make this an ocamldoc comment, it should be:

(** [%!] does nothing here. To flush the channel, use [Lwt_io.flush channel]. *)

The (** makes ocamldoc pick it up (so it is included in the generated manual), and the [...] is the ocamldoc source code style. I also took the liberty of not opening Lwt_io in channel, because that is likely to be a user's identifier, rather than something from Lwt_io when someone is using fprintf. But for print*f and eprint*f, it should probably be with Lwt_io as you have it, and Lwt_io.stdout and Lwt_io.stderr, respectively, rather than a user's identifier "channel".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I'm not sure what you mean by "not opening Lwt_io in channel".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the Lwt_io.(foo bar) syntax is a "local open," it brings the identifiers of Lwt_io in scope for both foo and bar.

So, for stdout, we probably want something like Lwt_io.(flush stdout), because that means "take both flush and stdout potentially from Lwt_io (or anything else that is in scope)."

But for a user's custom channel, Lwt_io.flush channel, because only flush here would come from Lwt_io.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry; I just saw this comment. Thanks for the explanation.

I addressed this in 5cd987d. Does it look okay?

In f103d78, I linked to Lwt_io.flush for the fprint*f docs. I tried to do the same for print*f and eprint*f, but I couldn't find a way to link to the identifiers flush and stdout in docs of the form Lwt_io.(flush stdout). Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it looks good now :) For the cross-reference links, I'd say just not to use them, because, as you can see, the support for including cross-references inside expressions is lacking, and you have to manually try to guess where to insert spaces around and inside [...], etc. It's difficult for most people to predict how that will be displayed, and it makes the .mli file hard to read.

The rule I use for myself is:

  • If it's a single identifier on its own, try to get it cross-referenced with {!...}.
  • If it's a non-trivial expression like Lwt_io.flush foo, don't try to get anything inside it cross-referenced, and just write it verbatim.

So, my suggestion is to omit f103d78.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc9328e reverts f103d78.

@aantron aantron merged commit 085cf1a into ocsigen:master Feb 13, 2018
@aantron
Copy link
Collaborator

aantron commented Feb 13, 2018

Thank you!

@smithjessk
Copy link
Contributor Author

My pleasure! Thanks for the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants