Skip to content

What generated methods should structs provide? #2372

Closed
@leafpetersen

Description

@leafpetersen

The struct proposal (#2360) specifies that a number of methods are automatically generated for structs. The core set, which I think are relatively uncontroversial, are equality, hashCode, copyWith method, and a default constructor are generated. In addition, I proposed a debugToString method to support debug printing in a way that is not tied to object interpolation and hence is less likely to accidentally cause type information to be retained unnecessarily (this is a common source of code size bloat in large applications).

The debugToString specification is only loosely thought through, @rakudrama had suggestions around using a more structured format.

It may also be desirable to include other generated methods, e.g. some way of providing general coding and decoding members (cc @jakemac53 )

This issue is for discussing the general question of what generated members to provide, and with what types and semantics.

It may prove useful to file sub-issues to discuss specific proposals, which can be linked in here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions