-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ditto mark feature #120
Comments
Interesting idea. I think it goes against the goal of keeping the language small and simple. I feel like this is solving something that is not really a problem. |
Also, consider this syntax: const fn_type_id = FnTypeId{
.is_extern = fn_proto.is_extern || (fn_proto.visib_mod == VisibModExport),
.is_naked = is_naked,
.is_cold = is_cold,
.param_count = node.data.fn_proto.params.len,
}; I feel like this accomplishes your goal, and this syntax is already implemented in Zig. (Of course, this is just one specific application of the ditto mark that you're proposing.) |
This feature was invented by old scribes to solve a real problem. Sentences which start with the same word(s) tend to be nuisance to type (or typeset) and hard to read. It gets worse for cryptic names so often used in code. Ditto would allow to break down scary blobs of letters and to spot repetition. @thejoshwolfe: yes, better initialization does help. But it is yet another single purpose feature. Ditto is more versatile: it could be used e.g. when one re-assigns several fields in a structure, or when one invokes several functions with the same parameters. Ditto can handle more than trivial initialization:
This is not explicitly stated priority of zig, as presented in the intro. Readability, however, is there. Last but not least: there are many languages vying for attention. To succeed language should provide advantage over competing ones. Ditto is natural and easy to use tiny feature. It doesn't need pages of explanation and examples. |
Better written with struct initialization.
This is not readable at all. I'm confident this will never be a feature of zig. |
Ditto mark is typographic feature to ease reading of repeated words. Source code is full of them.
Example from zig compiler code:
How it could be made more readable:
One look at the structure of code reveals the repetition, one does not need to mentally parse the same word again and again.
Rules of thumb may be employed to avoid ambiguities. E.g. the effect of
---
ends with empty line.The text was updated successfully, but these errors were encountered: