question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requesting 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:open
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
evhubcommented, Jul 7, 2016

@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,

flights |> group_by('year', 'month', 'day')

won’t work in Coconut, since it assumes group_by is a function, not a method. But now, you should be able to do

flights |> .group_by('year', 'month', 'day')

(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 that

flights |> .group_by('year', 'month', 'day') |> my_transform_func |> .select('arr_delay', 'dep_delay')

will work, which is much cleaner than in Python, where you’d have to do

my_transform_func(flights.group_by('year', 'month', 'day')).select('arr_delay', 'dep_delay')

which obscures the order in which the functions / methods are called.

1reaction
evhubcommented, Jun 21, 2016

Thanks for the issue! I’ll look into this and see what I can do for the next version.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found