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

fix enum to lower case #184

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

fix enum to lower case #184

wants to merge 4 commits into from

Conversation

chinsyo
Copy link

@chinsyo chinsyo commented May 6, 2019

No description provided.

Sodium/SecretStream.swift Outdated Show resolved Hide resolved
@jedisct1
Copy link
Owner

jedisct1 commented May 6, 2019

But... why?

It breaks all the tests and even the examples from the documentation.

@chinsyo
Copy link
Author

chinsyo commented May 6, 2019

But... why?

It breaks all the tests and even the examples from the documentation.

emmm... Cuz swift standard library do.

Sodium/PWHash.swift Outdated Show resolved Hide resolved
@jedisct1
Copy link
Owner

jedisct1 commented May 6, 2019

But the current names are consistent with the underlying C library.

Following Swift's convention is good, but this change is going to break all existing apps without any functional improvement.

I'll let @blochberger judge if it's worth it. But if such a change is made, it has to be made everywhere, including tests, examples and documentation.

@chinsyo
Copy link
Author

chinsyo commented May 6, 2019

But the current names are consistent with the underlying C library.

Following Swift's convention is good, but this change is going to break all existing apps without any functional improvement.

I'll let @blochberger judge if it's worth it. But if such a change is made, it has to be made everywhere, including tests, examples and documentation.

Thanks for your reply.

@blochberger
Copy link
Collaborator

But the current names are consistent with the underlying C library.

This is an implementation detail and in my case only relevant if references from the Sodium documentation would cause confusion – which I do not think is the case.

Following Swift's convention is good, but this change is going to break all existing apps without any functional improvement.

I think that this is a good point. However, some parts/ideas of the pull request might be worth giving it a bit more thought:

  • The SUCCESS/FAILURE cases could be replaced by the Result type introduced in Swift 5 (SE-0235).
  • default is a reserved keyword requiring special quoting – as your change shows. I think this is confusing and should be avoided. Maybe the Default case can be dropped in the enum altogether or renamed to defaultAlgorithm. Dropping the case requires more thought. Simply choosing the default algorithm for any unknown integer passed to the switch statement would be a bad choice. Calling the underlaying C-function in the function signature (this is what I do in Tafelsalz) might also not be the best choice.

I'll let @blochberger judge if it's worth it. But if such a change is made, it has to be made everywhere, including tests, examples and documentation.

I vote for closing the pull request for now. I could open issues for using the new Result type and for discussing how the Default algorithm could be handled more "swifty" – which I do not think is straight forward. What do you think @jedisct1?

@jedisct1
Copy link
Owner

jedisct1 commented May 6, 2019

If we are going to make breaking changes, using the Result type definitely looks like a good change to make.

Using quotes to work around existing keywords is painful. Renaming Default to defaultAlgorithm would work.

@blochberger
Copy link
Collaborator

Looking at ExitCode again, I see that it is only used internally, i.e., not communicated to the user. Regardless of which error occurred, nil is returned for all fallible functions. Hence, I think that using the Result type is not needed in that case.

@chinsyo
Copy link
Author

chinsyo commented May 7, 2019

Looking at ExitCode again, I see that it is only used internally, i.e., not communicated to the user. Regardless of which error occurred, nil is returned for all fallible functions. Hence, I think that using the Result type is not needed in that case.

Agree

@GoranLilja
Copy link

What's the status of this pull request? I got the impression that everyone is agreeing, yet the PR isn't merged. Friendly ping @blochberger who requested changes. 🙂

case Default
case Argon2I13
case Argon2ID13
case `default`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid ticks and name it defaultAlgorithm as @jedisct1 suggested.

case .Default: return crypto_pwhash_alg_default()
case .Argon2I13: return crypto_pwhash_alg_argon2i13()
case .Argon2ID13: return crypto_pwhash_alg_argon2id13()
case .`default`: return crypto_pwhash_alg_default()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid ticks and name it defaultAlgorithm as @jedisct1 suggested.

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

Successfully merging this pull request may close these issues.

None yet

4 participants