swift-sodium icon indicating copy to clipboard operation
swift-sodium copied to clipboard

fix enum to lower case

Open chinsyo opened this issue 5 years ago • 9 comments

chinsyo avatar May 06 '19 10:05 chinsyo

But... why?

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

jedisct1 avatar May 06 '19 10:05 jedisct1

But... why?

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

emmm... Cuz swift standard library do.

chinsyo avatar May 06 '19 10:05 chinsyo

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.

jedisct1 avatar May 06 '19 11:05 jedisct1

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.

chinsyo avatar May 06 '19 11:05 chinsyo

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?

blochberger avatar May 06 '19 11:05 blochberger

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.

jedisct1 avatar May 06 '19 12:05 jedisct1

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.

blochberger avatar May 06 '19 22:05 blochberger

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

chinsyo avatar May 07 '19 01:05 chinsyo

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. 🙂

GoranLilja avatar Feb 28 '20 09:02 GoranLilja