Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Struct{}/Union{} (and maybe Enum.value?) #6210

Closed
tadeokondrak opened this issue Aug 31, 2020 · 3 comments
Closed

Remove Struct{}/Union{} (and maybe Enum.value?) #6210

tadeokondrak opened this issue Aug 31, 2020 · 3 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.

Comments

@tadeokondrak
Copy link
Contributor

This was mentioned in #3652 but I don't think it got much discussion after that.

Structs/unions:

make zig fmt convert Foo{.a = b} to @as(Foo, .{.a = b}), wait 1 release cycle, and remove the deprecated old syntax. If this looks bad to you, consider that most struct literals will look like this: const foo: Foo = .{.a = b};.

Enums:

That's a good point - you could make an analogy with Enum.name being redundant with @as(Enum, .name).

@daurnimator
Copy link
Contributor

daurnimator commented Aug 31, 2020

Note #3652 (comment)

let's leave it be for a bit, and see how it feels. If it makes it worse in practice to use @as(Foo, .{.a = b}) rather than Foo{.a = b}, then it's worth considering to keep the redundant syntax.

@daurnimator daurnimator added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Aug 31, 2020
@tauoverpi
Copy link
Contributor

If .{} worked with error unions this wouldn't probably be too much and the same with [_]T{} in the case of &[_]T{}. then it would possibly be better at the cost of being slightly more noisy.

@Vexu
Copy link
Member

Vexu commented Aug 31, 2020

Duplicate of #5038

@Vexu Vexu marked this as a duplicate of #5038 Aug 31, 2020
@Vexu Vexu closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

4 participants