Skip to content

Internal: API for safe boxes#1074

Closed
gpetiot wants to merge 10 commits intoocaml-ppx:masterfrom
gpetiot:safe-box
Closed

Internal: API for safe boxes#1074
gpetiot wants to merge 10 commits intoocaml-ppx:masterfrom
gpetiot:safe-box

Conversation

@gpetiot
Copy link
Copy Markdown
Collaborator

@gpetiot gpetiot commented Oct 14, 2019

I started working on a better way to use boxes:

  • no box if there is less than 2 elements (we still need to detect Fmt.noop later), but can box 1 element if we use a flag (we should try to eliminate these cases later)
  • enforce the use of a separator between 2 elements
  • still compatible with the type Fmt.t

So far it is used inside a Safe module to distinguish with the legacy (soon unsafe) functions, the substitutions in legacy code would be done step by step as there is a lot of code to be modified, but it would be nice to use this API for bugfixes and new developments.

Add box names after #1083 is merged.

Copy link
Copy Markdown
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

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

Could you give an example of how it's used ?

@gpetiot
Copy link
Copy Markdown
Collaborator Author

gpetiot commented Oct 15, 2019

Could you give an example of how it's used ?

I added an example in Fmt_ast (unfortunately it requires an additional parameter ~box_singleton for this one)

@gpetiot gpetiot changed the title Improve: API for safe boxes Internal: API for safe boxes Oct 16, 2019
Copy link
Copy Markdown
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

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

Can you show an example in the code where we need to remove boxes if there is only one element ?
Also, can't this be solved by conventions and less intrusives Fmt functions ?

What do you think of a simpler box_list : (t -> t) -> ?sep:t -> t list -> t that would do the logic in box_if ?

@gpetiot
Copy link
Copy Markdown
Collaborator Author

gpetiot commented Nov 14, 2019

Closing for now

@gpetiot gpetiot closed this Nov 14, 2019
@gpetiot gpetiot deleted the safe-box branch November 14, 2019 10:14
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.

3 participants