-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconsider topic names as variable names #1919
Comments
Add an error when name and varname are different. Error should explain why. |
String should be translated to var name capitalization. ie var name changes per language (idiomatic) |
Do the same for name string literal? Think about it |
Currently, given a topic declaration: The issue is if we generate the idiomatic variable name The options I'm seeing are either to constrain the topic names (say, to lower snake), which feels too prescriptive, or to just enforce that the varname be the same as the topic name with the first letter capitalized ( |
Actually, unless I'm missing something, I don't think we do ever go from generated variable name back to topic name, despite what this comment implies: Which means for the go generator template, we could use the topic Just need to add a new string conversion func for |
Aaand I might be mistaken. Not sure what the clean solution is here. |
I honestly don't know a good solution to this. I'm tempted to go down the path of a single allowed format for the topic name string... That way we can deterministically transform from the var name to it. Or we figure out a way to make the compiling work where we never need to derive the topic name from the variable name. I guess you could do this by doing a first pass where you collect all the variable names + topic name pairs, and then refer to that mapping whenever we find a topic variable used. Then it doesn't matter that variable name loses information from the topic name. Maybe that second one is best? Throwing out some other options that probably aren't as good...
|
Went down the path of not deriving the topic name by instead looking it up in the ast during analysis, and potentially storing the varname to topic name mapping as an analysis fact, but another issue we discovered (thanks @worstell!) is that the analysis isn't done on the stubbed code. Expanding the analysis to include that isn't trivial; it might make sense if we need that info for anything else, but doesn't seem worth it for this issue. I'm also leaning towards being prescriptive about topic names (let's say |
When defining a topic, this is the code:
var VarName = ftl.Topic[EventType]("name")
When we export a topic, this is the code we generate
var Name = ftl.Topic[EventType]("name")
I think this breaks the mental model people have when switching between modules as the variable they exported in one module is not the name to access it in another.
Also:
The text was updated successfully, but these errors were encountered: