Open felixangell opened 9 years ago
As long as the first syntax option (the one using the alias
keyword) doesn't introduce some syntax ambiguity for the parser (as the keyword may also be used for type aliases), then I would say it is the better option.
Also, would it not fit with the language a little more if you were to put the alias name before the assignment operator? This would fit with the syntax used for variable assignments, rather than reversing it.
So for example:
alias [x] = [a, b, c]
rather than:
alias [a, b, c] = [x]
I think it should be like this:
attr @[x] [a, b, c]
@SamTebbs33 Yeah that looks like it makes sense. @MovingtoMars As for attr
, I understand it's to avoid ambiguity, but it seems kind of random.
@ark-lang/owners Conclusion to be drawn here!!! Or ideas if you disagree with all of the stuff above ^^^
:-1: On attributes groups. Realistically, I don't think most attributes would be used to the point where that would help.
:+1: for the revival attribute blocks, although i agree that the previous syntax should be changed..
@kiljacken Do you mean attribute blocks? Or do you mean grouping attributes under a single attribute. What do you mean by the revival of attribute blocks?
@felixangell I was thinking of the scenario of writing bindings to a c library. It would be nice to do something like:
[c] {
func some_library_function()
func some_other_library_function()
func some_third_library_function()
}
It's not a big deal tho
@kiljacken I'm down with attribute blocks, that's primarily the reason I wanted them :+1:
We think that the current idea for attribute blocks:
Is not a great solution for attribute blocks, because they should not introduce a scope, yet we feel by adding this rule to the compiler it's somewhat misleading and inconsistent with the syntax of the language.
Because of this, we think it's best to re-think attribute blocks. And instead of having literal attribute blocks, you have "attribute groups". In other words, you have a couple of functions where you're always using the attributes,
a, b, c
. So you group this under a general attribute, for instancex
. Then instead of writing[a, b, c] func...
, you can simplify it down to[x] func...
. Since it's in essence an alias or a variable, it's also easy to add more attributes under the general attributex
, and also easy to remove them too.The syntax for this feature is still in the works, but we have a few ideas. Before I go on to those, we wanted to add a way of differentiating various attributes that are defined by the developer; compiler; and are a group of attributes. So we've come up with the following syntax:
[attribute]
- compiler defined attribute;#[attribute]
- developer defined attribute;@[attribute]
- group/alias of attributesNow to define a group of attributes, we aren't too sure, but we have a few ideas:
And that's it! Feedback, suggestions, etc... are greatly appreciated.
@ark-lang/owners