Skip to content

Support field in dataclass member initialization - #2280

Merged
ubaidsk merged 2 commits into
lcompilers:mainfrom
ubaidsk:support_field_in_dataclass_mem_init
Aug 17, 2023
Merged

Support field in dataclass member initialization#2280
ubaidsk merged 2 commits into
lcompilers:mainfrom
ubaidsk:support_field_in_dataclass_mem_init

Conversation

@ubaidsk

Copy link
Copy Markdown
Collaborator

towards #2276

@ubaidsk
ubaidsk marked this pull request as draft August 16, 2023 23:38
@ubaidsk
ubaidskforce-pushed the support_field_in_dataclass_mem_init branch from 4a10c8b to 9bdb90eCompareAugust 16, 2023 23:40
@ubaidsk
ubaidsk marked this pull request as ready for review August 16, 2023 23:45
@ubaidsk
ubaidsk requested a review from certikAugust 16, 2023 23:50

@certikcertik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good.

b: bool = True
c: list[i32] = field(default_factory=lambda: [1, 2, 3])
d: i32[3] = field(default_factory=lambda: array([4, 5, 6]))
e: i32 = field(default=-5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same as:

Suggested change
e: i32=field(default=-5)
e: i32=-5

?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think they are equivalent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are equivalent, then I would almost not support the duplicate way of doing it ("just one way of doing things").

@ubaidsk
ubaidsk merged commit b70bfdf into lcompilers:mainAug 17, 2023
@ubaidsk
ubaidsk deleted the support_field_in_dataclass_mem_init branch August 17, 2023 06:05
@ubaidsk
ubaidsk restored the support_field_in_dataclass_mem_init branch August 17, 2023 06:06
@ubaidsk
ubaidsk deleted the support_field_in_dataclass_mem_init branch August 17, 2023 06:07
Sign up for freeto 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.

2 participants

@ubaidsk@certik