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

Deparsing API #636

Closed
lionel- opened this issue Sep 29, 2018 · 5 comments
Closed

Deparsing API #636

lionel- opened this issue Sep 29, 2018 · 5 comments

Comments

@lionel-
Copy link
Member

lionel- commented Sep 29, 2018

Meta-issue about the deparsing API:

Naming

  • I'm not sure why we duplicated the API with expr_ and quo_ functions. Isn't it simpler to just treat quosures as any other language type and deal with them in expr_ functions as well?

  • Perhaps relevant for naming: These functions are about pretty printing, while expr_deparse() is about transferring R objects as text. Though the latter also has pretty printing features such as omitting the last n elements of vectors.

  • The naming of expr_text(), expr_name() etc generally suggests they are accessors. In reality they are actions (deparse variants).

  • Are expr_name() and quo_name() misnomers? It seems it should only be used to provide default names for quoted arguments that might be complex expressions. I often see it used for transforming symbols to strings, which should better be done with as_string() or as.character() (the former works better on Windows with foreign characters).

    Perhaps expr_pretty_name() would be more suggestive that it's about default names?

Features

  • Do we need a _line() variant? We are using _name() for backtraces, it seems we are really after line. It should try to deparse as much of an expression as possible while keeping it on a same line and within peek_option("width"). It should take a column position as argument to be substracted from width.
@hadley
Copy link
Member

hadley commented Oct 5, 2018

Maybe _abbr, _line, _full

And maybe deparse_, or label_?

lionel- added a commit that referenced this issue Oct 8, 2018
Use label() to create default names. Currently unexported.
Part of #636
@lionel-
Copy link
Member Author

lionel- commented Oct 16, 2018

Squash quosures with the label variant but represent them with ^ with the other variants?

lionel- added a commit to lionel-/rlang that referenced this issue Dec 21, 2018
Should be used instead of `quo_name()`

Part of r-lib#636
lionel- added a commit to lionel-/rlang that referenced this issue Jan 3, 2019
Should be used instead of `quo_name()`

Part of r-lib#636
@lionel- lionel- mentioned this issue Jan 24, 2019
@krlmlr
Copy link
Member

krlmlr commented Apr 26, 2019

I was searching for quo_text() but didn't find this issue. Good it's linked from the docs ;-)

Is it safe to use quo_text() for now?

@lionel-
Copy link
Member Author

lionel- commented Apr 26, 2019

If you need a multi-line deparser yes. It'll go through a long lifecycle of deprecation.

@lionel-
Copy link
Member Author

lionel- commented Apr 21, 2021

Discussion continues in #1173.

@lionel- lionel- closed this as completed Apr 21, 2021
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

3 participants