Skip to content
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

[Suggestion] rename ftl.Map #1346

Closed
mistermoe opened this issue Apr 27, 2024 · 1 comment
Closed

[Suggestion] rename ftl.Map #1346

mistermoe opened this issue Apr 27, 2024 · 1 comment
Labels
triage Issue needs triaging

Comments

@mistermoe
Copy link
Collaborator

Note

Feel free to close this issue if y'all think otherwise! no hard feelings whatsoever. Just something that crossed my mind when i initially came across the function when looking for ftl.Singleton:

ftl.Map feels a wee bit ambiguous. i think folks would instinctively think of a map[string]any sort of map prior to thinking: "Map this resource to this function".

If someone did go as far as hovering over Map to read the godoc, it sort of makes it sound like you're using Map to create a binding between a resource and a function so that anywhere the resource is fetched, that function would execute instead. Maybe ftl.Use or ftl.UseResource would be more clear.

image
@github-actions github-actions bot added the triage Issue needs triaging label Apr 27, 2024
@mistermoe mistermoe changed the title Suggestion: rename ftl.Map [Suggestion] rename ftl.Map Apr 27, 2024
@alecthomas
Copy link
Collaborator

alecthomas commented Apr 27, 2024

I think most programmers today are familiar with the concept of "map" as a higher order function, so I think the name is fine. Also the signature makes it very clear it's not related to a map data structure. If anything I think Use is more confusing, to me personally at least?

Maybe the docs could change to reflect its purpose better though? But another option might be making it a method on the Handle interface, though that means that every resource type would have to implement that method, which would be annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issue needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants