Live data from Hacker News

Macros in Python

github.com

31–40 of 71 posts

Re: Macros in Python

#31
I really liked this up until the inheritance bit.

Child classes have to be nested classes of the parent doesn't sit right with me. Also, wouldn't it be better if these classes inherited object in some way?

For the record, I liked everything else that it mentioned. Just the inheritance bit was something I didn't like.

Re: Macros in Python

#33
post #31

I really liked this up until the inheritance bit. Child classes have to be nested classes of the parent doesn't sit right with me. Also, wouldn't it be better if these classes inherited object in some way? For the record, I liked everything else that it mentioned. Just the inheritance bit was something I didn't like.

- The classes do inherit from object, iirc - We know the nesting is controversial; whether it will remain in its current form has yet to be seen. I think there is some merit in this way of doing it, we know others disagree

Re: Macros in Python

#34
post #27

Earlier quoted context omitted.

We do take it seriously; it's a hard tradeoff between Novelty and Utility. Given that the whole point of macros is to change the semantics of the Python language, this (valid) criticism applies not just to case classes but macros in general. If you go haywire with macros, all hell breaks loose. We think that with some discipline, it is possible to come up with macro transformations which are both useful and understan…

The implementation of namedtuple is pretty crazy, but the interface is simple and doesn't change the language semantics.

I'd argue that "fields as a string with spaces inside, or maybe a list of strings" is changing language semantics quite a bit.

We're used to namedtuples doing it like this now, but if namedtuples didn't exist, "fields as a list of strings with spaces inside, or maybe a list of strings" would definitely not make it past code review and probably get me yelled at by my future colleagues.

Re: Macros in Python

#35
post #28

It's a cool idea, but this basically sneaks new features into the Python language through a backdoor, bypassing the public review/feedback process. I would suggest the author create a PEP for these features instead.

Given the language's general trend away from functional programming and Guido's flat-out refusal to implement TCO, I think starting with an implementation, showing interest (if it exists), and then trying to standardize via PEPs is probably a reasonable route to go.

Re: Macros in Python

#36
post #33
post #31

I really liked this up until the inheritance bit. Child classes have to be nested classes of the parent doesn't sit right with me. Also, wouldn't it be better if these classes inherited object in some way? For the record, I liked everything else that it mentioned. Just the inheritance bit was something I didn't like.

- The classes do inherit from object, iirc - We know the nesting is controversial; whether it will remain in its current form has yet to be seen. I think there is some merit in this way of doing it, we know others disagree

Ah, okay.

Honestly, if I have classes that really do need to inherit from each other, I probably won't be using @case to do it anyways. I see this being extremely useful for the many structures that I need in my application (that may require a few convenience methods) more than anything.

Re: Macros in Python

#37

This is awesome. Everything here (except the anonymous arguments to lambdas, seriously, just use x y and z as default argument names) should be in Python 4 or whatever you'd want to call the successor to Python. I love love love the PEG implementation.

I agree nice clean work, so many try to simply "out do" with elegance and "smart code". Clean and simple is a gem hard to find. I will gladly contribute going forward.

Re: Macros in Python

#38

This is awesome. Everything here (except the anonymous arguments to lambdas, seriously, just use x y and z as default argument names) should be in Python 4 or whatever you'd want to call the successor to Python. I love love love the PEG implementation.

I agree nice clean work, so many try to simply "out do" with elegance and "smart code". Clean and simple is a gem hard to find. I will gladly contribute going forward.

Re: Macros in Python

#39

This is awesome. Everything here (except the anonymous arguments to lambdas, seriously, just use x y and z as default argument names) should be in Python 4 or whatever you'd want to call the successor to Python. I love love love the PEG implementation.

I agree nice clean work, so many try to simply "out do" with elegance and "smart code". Clean and simple is a gem hard to find. I will gladly contribute going forward.
Post reply on HN