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

Refactor interp() #15

Merged
merged 13 commits into from Jan 9, 2017
Merged

Refactor interp() #15

merged 13 commits into from Jan 9, 2017

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Jan 3, 2017

  • Remove old lazyeval's interp generic
  • Rename f_interp() to interp() and add interpolation of closures.
  • Capitalise all unquoting functions.
  • Let UQS() handle language objects. This is useful for interpolating bodies of closures.
  • Add !!, !!!, and `!!`() shortcuts for unquoting and splicing.

@@ -319,8 +319,8 @@ fml_default <- function(expr, fn) {
#' @export
#' @examples
#' # The missing argument can be useful to generate calls
#' f_interp(~f(x = uq(arg_missing())))
#' f_interp(~f(x = uq(NULL)))
#' interp(~f(x = UQ(arg_missing())))
Copy link
Member

Choose a reason for hiding this comment

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

Did you want to use !!?

Copy link
Member Author

Choose a reason for hiding this comment

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

so should we promote !! as the default way of unquoting? I'd like that.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think so

#' with the evaluated value of \code{x}, and inlines sub-expressions
#' of the form \code{UQS(x)}. Syntactic shortcuts are provided for
#' unquoting and unquote-splicing by prefixing with \code{!!} and
#' \code{!!!}.
Copy link
Member

Choose a reason for hiding this comment

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

I'm still not sure about !!!.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really like it but it's your call ;)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, let's just go with it. I can't see an option that's better (unless we use !!. or !!?)

#'
#' # However you need to be a bit careful with operator precedence.
#' # All arithmetic and comparison operators bind more tightly than `!`:
#' interp(x ~ 1 + !! (1 + 2 + 3) + 10)
Copy link
Member

Choose a reason for hiding this comment

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

Oh that's a major downside 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

yes :/

@lionel- lionel- merged commit 436b970 into r-lib:master Jan 9, 2017
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.

None yet

2 participants