Hi @michelf, that is indeed an important topic, so let me explain more.
Expanding the grammar for escaped identifiers will still respect any current semantic constraints.
As an example, $ dollar identifiers are still compiler-reserved names, `$identifierNames`
will produce an error. This means that even if the parser allows you to potentially declare something, it does not necessary mean that semantically you can.
Same goes for operators, if an escaped identifier can be "processed", in its context, as an operator then it will be an operator and therefore any logic associated to this set of identifiers will apply.
As for this, it is an operator function, for example moving inside the declaration of a struct
the compiler will prompt to Operator '+' declared in type 'Int' must be 'static'
as it would do for the a non escaped version.
Thanks Jeremy for giving an insight of the pitch discussion.
I want to slightly correct this sentence and make it clear. We do not explicitly check for the first character, but instead the compiler check if the whole identifier can be an operator (obviously if the first char is not an operator we already know that the whole identifier is not an operator). This choice didn't increase complexity, instead it made simpler as those checks were already in place. For the record, `+a`()
would be considered a function.
Yes, referencing operator was considered a nice side effect and not really the main goal.
I was playing around with BDD and you could do (take it as a proof of concept) something like this:
func `test account has sufficient funds`() {
given(`the account balance is`(100.dollars)) {
and(`the card is valid`)
}
.when(`the account holder requests`(20.dollars))
.then(`the account balance should be`(80.dollars))
}
The different methods (`the account balance is`
, `the card is valid`
etc..) can be used for setting up the test or asserting a particular condition. I personally find the fact of being able to explore opportunities like this one exciting. I do also understand, and respect, that some of us may still want to prefer the camelCase option (or not).
Said so, Michel, I hope this helps for your review, in particular, I hope it clarified your doubts about operators, if not, please let me know which other questions you may have, I would be happy to reply to those