On 3/11/2021 10:23 AM, Ricky Teachey wrote:
On Thu, Mar 11, 2021 at 10:20 AM Paul Bryan <pbryan@anode.ca> wrote:
Given that @dataclass is a decorator, and otherwise you're just defining a class, some concerns:
1. Such proposed syntax would require a change to the language specification.
2. It would seem that / and * in a class not decorated with @dataclass would be of no other utility.
Paul
Well the utility of this, without dataclasses, or only for the type checker as far as I know:
class C:member: Any
Perhaps the additional syntax could also be useful for the type checker?Type checkers certainly have to be aware of the generated __init__, so they're definitely involved.
As long as we're going all "pie in the sky", I'd like to see dataclasses baked in to the interpreter. Something like:
dataclass Point:
x: int
y: intThat's actually a typo I make all the time!
But I don't think there's really any chance of doing anything requiring changes to the interpreter. So we're back to either using field() or my marker types. Any other ideas that could be implemented today? I don't think the "with" suggestion could be made to work, but maybe I lack imagination.
Eric