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

[discussion/feature request] adding match guards to group_names/1 #81

Open
flaviogrossi opened this issue Apr 11, 2024 · 0 comments
Open

Comments

@flaviogrossi
Copy link
Contributor

Hi, this is mainly a discussion before trying to implement a new feature.

In my current use case, a number of process groups is created, using a name like {:group_x, :subgroup_y}, (for example the names are {:group_1, :subgroup_1}, {:group_1, :subgroup_2}, {:group_2, :subgroup_1}, ...)

Then, for example, i need to retrieve all existing subgroups for a given group, with something like :syn.group_names(scope) |> Enum.filter(fn {group_name, _} -> group_name == :group_1 end).

Since this is becoming quite inefficient, due to the filter call, i was wondering if it was desired to add a new api, group_names_match/2 which mimics the match function in the elixir registry.

The implementation would simply be something like adding a new parameter to group_name_ordset which is then used here as a guard on the ets select, and then expose a new function group_names_match which will be called like group_names_match(scope, [{:==, :"$1", {:group_1, :_}}]).

What do you think? I can work on a pull request if this seems interesting.

Or should i simply use a different scope for every group_x (which is fixed) in my use case?

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

No branches or pull requests

1 participant