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

Implement calling_env() #70

Closed
wants to merge 1 commit into from
Closed

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Feb 23, 2015

This implements a helper function that makes it easy to retrieve the original environment that called a pipe chain. This will help magrittr-aware tools to reinforce the idiom that a pipe chain is one single function entity.

Another way of implementing this would be to climb the calling stack dynamically, looking for magrittr's anchors (_fseq, _function_list, etc). This way calling_env() would work when called in functions embedded deeply in pipe components. If we start from n = 5, there would be no cost when calling_env() is called from the top level of a pipe component. But I suspect it may get very costly if called outside of a pipe chain and the calling stack is large.

@krlmlr krlmlr mentioned this pull request Oct 9, 2015
@hadley
Copy link
Member

hadley commented Jul 2, 2018

Fixes #171

@lionel-
Copy link
Member Author

lionel- commented Jul 3, 2018

We should probably use a different approach, like a marker environment installed in the data mask / exec-env. Ideally magrittr wouldn't use a child environment at all.

@smbache
Copy link
Member

smbache commented Jul 3, 2018

This should be so much simpler in the suggested approach where everything is evaluated in that one function

@lionel-
Copy link
Member Author

lionel- commented Jul 3, 2018

I think it might make sense to evaluate magrittr expressions directly in the calling environment, I'll reply to the thread with Hadley soon!

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