When a @foo is considered an attribute and when it's not
#2945
Replies: 4 comments 1 reply
|
There is only a few built-in attributes, however, user-defined ones are starts with capital letter: |
|
Allow me to express my concern about this current state of syntax. On one side, we want to avoid using existing operators to do multiple things, such as the case of the ternary operator Isn't there a way to get rid off of this unnecessary fuss to avoid future nightmares that could lead to further language and syntax complexity? |
|
Another thing that I've just thought was a naive way to disambiguate the usage of Would it be wrong to replace the macro syntax to match that of Rust's? In other words, this example fn void UrlQueryValues.free(&self)
{
self.map.@each(;String key, UrlQueryValueList values)
{
foreach (value: values) value.free(self.allocator);
values.free();
};
self.map.free();
foreach (&key: self.key_order) key.free(self.allocator);
self.key_order.free();
}would become fn void UrlQueryValues.free(&self)
{
self.map.each!(;String key, UrlQueryValueList values)
{
foreach (value: values) value.free(self.allocator);
values.free();
};
self.map.free();
foreach (&key: self.key_order) key.free(self.allocator);
self.key_order.free();
}I think this would improve readability by orders of magnitude! |
|
there is a little more nuance--they're also after generic params in a generic declaration for example--but they can only appear in places that macros can absolutely never appear. |
Uh oh!
There was an error while loading. Please reload this page.
I'm using Vim editor and have noticed some keywords are not highlighted which I plan to fix and push a PR.
As the title says, when a
@fookeyword is considered an attribute and when it's not?I know we use the same
@operator inside theDoc contractswhich makes the whole situation more confusing...If we open the module
lib/std/net/url.c3, we can see unhighlighted keywords, such as@pool(),@ok(a_keyword_in_here),@stack_mem(128; Allocator smem), and of course, the most confusing part can be found infn void UrlQueryValues.free(&self)which looks like this:The
self.map.@each()...what is supposed to mean here?!Can anyone enlighten me so I know which keywords need to get set as attributes in Vim editor so I can PR as soon as possible?
All reactions