Hygenic Macros
See original GitHub issueRequesting Hygenic Macros like in macropy: https://github.com/lihaoyi/macropy
Its useful for example to refer to the columns of a dataframe of object in a formula or expression that is later expanded without being eagerly evaluated :
lm(y~x,df)
mutate(flights, gain = arr_delay - dep_delay, speed = distance / air_time * 60)
Or write more complex arbitrary domain specific languages for data analysis packages.
Relevant PEP: https://mail.python.org/pipermail/python-ideas/2015-March/032822.html
More use cases: http://multithreaded.stitchfix.com/blog/2015/03/17/grammar-of-data-science/
CC: @shoyer who might be interested in coconut as a Pydata DSL (with piping, and lots of other functional goodness, compiles to valid python 2/3, 100% compatible with python 3 etc) and this issue specifically.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Hygienic macro - Wikipedia
Hygienic macros are macros whose expansion is guaranteed not to cause the accidental capture of identifiers. They are a feature of programming languages ......
Read more >Hygienic Macros : An Introduction - GeeksforGeeks
Hygienic macros are macros whose expansion is guaranteed not to cause the accidental capture of identifiers. A hygienic macro doesn't use ...
Read more >Hygienic macros - syntax-case
Hygienic macros ¶. In episode 9 I noted that Scheme provides three major macro systems (syntax-rules, syntax-case and define-macro), yet I went on...
Read more >Why Hygienic Macros Rock | Random Hacks
Hygienic macros are (essentially) macros which Do The Right Thing with local variable names. They're controversial because Doing The Right ...
Read more >Hygiene
Macros in Rust are partially hygienic. Specifically, they are hygienic when it comes to most identifiers, but not when it comes to generic...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@datnamer @TomAugspurger It doesn’t resolve this issue, but I thought you should know that in v1.1.1, I added a methodcaller implicit partial, which I believe should be a big help in using libraries like pandas with Coconut, since, because Python lacks pipes,
pandas
uses methods for everything. Thus,won’t work in Coconut, since it assumes
group_by
is a function, not a method. But now, you should be able to do(note that the only change was adding a
.
) which will allow you to mix and match methods and custom functions when using pipeline-style programming, so thatwill work, which is much cleaner than in Python, where you’d have to do
which obscures the order in which the functions / methods are called.
Thanks for the issue! I’ll look into this and see what I can do for the next version.