3 ms·
> However I don't like that they start with an underscore Early on _[A-Z] meant reserved variable so that's why it's currently _On. Many keywords are a single
by levodelellis 4y ago
> However I don't like that they start with an underscore
Early on _[A-Z] meant reserved variable so that's why it's currently _On. Many keywords are a single word and common enough that it shouldn't bother anyone that it's reserved. However I'm not great coming up with a style guide. On empty is two words, I have no idea how it should be written and everyone seems to have their own style.
Do you have a suggestion for the _On keywords?
> Why not only one? The compiler should know what to do because of the mut, out keywords
You noticed the out keyword? It's not recommended we only use that to interface with C code. Returning multiple variables is much better IMO (I won't speak for everyone). Accumulator and dynamic arrays are common enough that I didn't want to force people to write mut each time. It's simply `:=`
- pmontra 4y ago> Do you have a suggestion for the _On keywords? Let's suppose that in the future you want to add an argument to the break keyword to signal why the loop returned early. I use a string (btw, does the language have symbols / atoms?) break "found" break "eof" break "invalid input" Then you could have on "found" on "eof" on "invalid input" with only one keyword. And on "complete" on "empty" > Returning multiple variables is much better IMO I agree but declaring a name for what you return is nice because it explains the purpose of the returned values. They could go outside the ()s. stat(file) out length, created, modified
- levodelellis 4y agoI'm thinking more about your suggestion but off the top of my head I don't know why one would want a break reason. If one comes up anytime soon I'll 100% remember this post > I agree but declaring a name for what you return is nice because it explains the purpose of the returned values. They could go outside the ()s. So you're not suggesting an 'out' keyword your saying names on return values? I like the idea but in practice I'm not sure if any IDE would show you the names? I think many do show comments if you place them the line before so that could be an alternative solution One reason I don't like out params is because it conflicts with the design of the language. The language prefers you to assign variables and people will want to modify their variables (or arrays and struct members) with the out param and having something be declare OR assign causes problems because its too easy to make a typo and not find it for many many minutes. Writing the type then using out goes against the flow of the language which is why I prefer returning multiple values. But I don't know all the use cases and everyones preference so there very well be a good reason you'd want an out parameter