Re:A Cross-Platform String Library Written in Swift
by TazeTSchnitzel on Sunday March 05, 2017 @01:53PM
(#13797740)
> 1) Function names are misleading or not descriptive enough. E.g. isAlpha(). I assumed this meant is alphanumeric, but it actually means isAlphabetic
Why should it mean alphanumeric? C's isalpha() also tests for being a letter, for instance, and has isalnum() for alphanumericness.
> If it's not uppercased of course its lowercased
If you're working exclusively with ASCII and ignoring non-letter characters, yes. But is this library bound by those constraints?
Re:A Cross-Platform String Library Written in Swift
by setr on Sunday March 05, 2017 @05:23PM
(#13799172)
what non-letter character should succeed in both isLowercase and isUppercase?
Re:A Cross-Platform String Library Written in Swift
by TazeTSchnitzel on Monday March 06, 2017 @04:17AM
(#13801577)
None. But letters can be neither lowercase nor uppercase.
Re:A Cross-Platform String Library Written in Swift
by setr on Monday March 20, 2017 @02:21AM
(#13912159)
In which case, the function(s) should really be throwing some kind of error, since they can't reasonably be applied to the input.
But checking !(isUppercase(str) || isLowercase(str)) to see if its not case-able(?) is absurd
Obviously you'd instead want the function notCaseable(str).
1) Function names are misleading or not descriptive enough. E.g. isAlpha(). I assumed this meant is alphanumeric, but it actually means isAlphabetic (as in no numeric values at all). isAlphanumeric() clears this up, but just call the first isAlphabetic and remove any ambiguity. 2) Explicit binary inverts; e.g. isUppercased(), isLowercased(). This leads to bad coding style as conditionals that point in the affirmative usually leads to easier to read code. If it's not uppercased of course its lowercased, so why keep a function around to point this out? Save on the cognitive load on the users and just keep one around. Let them negate it for the desired result.
Otherwise, thank you for contributing what looks to be a pretty handy library that isn't tied to just MacOS/iOS and Xcode. I'm really starting to enjoy Swift and am curious to use it in non-client environments soon and a library like this is a pretty nice tool to have.