-
Notifications
You must be signed in to change notification settings - Fork 17
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
Problem: end
is a keyword
#26
Comments
I'm torn on this. I'm tempted to say that the code compiles: why change unless we have to? On the other hand I can see the annoyance in breaking syntax highlighting, and who knows if our code will always be valid? Breaking backwards compatibility now is better than later, especially when we could have seen this comming. Since we have a fair number of downloads (6k), we do need to issue a deprecation warning first. I'm not sure how to do that with struct keys, though. |
I would assume that most users do not directly use the start and end fields of the struct, but rather the My idea is to add functions that work as accessors to the struct and to treat the struct itself as an opaque object that no project should work directly with. So we would introduce a # For example:
x = "127.0.0.1/24" |> CIDR.parse
first = x |> CIDR.first
last = x |> CIDR.last Does it make sense? |
Another idea is to add |
Solution: add additional first/last fields and deprecate start/end See #26
end
is a (reserved?) keyword in Elixir, which we should avoid as a struct field name, see:https://github.com/elixir-lang/elixir/blob/7b5f4a5842d05bf279b249078fd9051e3dcafa50/lib/elixir/src/elixir_tokenizer.erl#L1037
While this does not cause problems in actual code yet (except broken syntax highlighting), I would strongly advise to change the CIDR struct members
start
/end
tofirst
/last
.This will break backward compatibility, but I think it is better to change it now than later.
@duijf what do you think?
The text was updated successfully, but these errors were encountered: