flatc for Swift modifies variables / labels for keywords #7333
Replies: 5 comments 4 replies
-
It was just since open is a main keyword in the swift programming language we would rather not use it as is. |
Beta Was this translation helpful? Give feedback.
-
I think that is a bit harsh, you may use swift keywords everywhere else in the language if enclosing them in backticks - |
Beta Was this translation helpful? Give feedback.
-
From the Swift documentation:
|
Beta Was this translation helpful? Give feedback.
-
I mean we can definitely try that as long as the over head of the change isn't big. Because the lib was migrated to use a central namer, and as long as its for variables.
That's my personal opinion, and i usually go for that option when writing code |
Beta Was this translation helpful? Give feedback.
-
Thanks @hassila, actually I was not familiar with backtick feature, it looks as very nice solution. @mustiikhalil , if you don't mind I'll do PR with backtick changes, will try to make them very compact. Thanks for your input guys! |
Beta Was this translation helpful? Give feedback.
-
I'm playing with FlatBuffers for my project and found some interesting behaviour.
I have simple schema:
then I generate Swift code for it. Variables last and close are named last and close, but open becomes open_. As far I understand it happens because there is a keyword open in Swift, but language doesn't prevent me to use open as variable name or label in function. If I tweak the generated code it compiles and works normally.
Is there any special reason to avoiding using such keywords as is in generated code? I'm curious since I'm going to use some autogeneration code on top of FlatBuffers generated code and don't want to handle keyword separately while they actually works as is.
In general I understand that changing this behaviour will lead to API break, but I see at least two options:
If there is no objection should I convert this to an issue and fix it?
@mustiikhalil, since Swift part is in your responsibility, may you please give a hint?
Beta Was this translation helpful? Give feedback.
All reactions