News for hackers. Stuff that matters.
Re:Custom string delimiters in Swift 5 by saagarjha on Friday December 28, 2018 @04:11AM (#18775707)
> Anyway, these types of operations come up all the time when working with strings, and these operations are really really incovenient in Swift.

Again, what are these operations? I think most of the issues people have with String is due to hard to discover APIs rather than design issues with String.

Re:Custom string delimiters in Swift 5 by jakobegger on Friday December 28, 2018 @12:54PM (#18778253)
Text parsing is something that comes up often (for me). For example parsing CSV files, or parsing tab separated data from the clipboard, or parsing various types of config files.

Swift has sweet solutions for a few special cases (eg. parse file names, parse dates, parse JSON), but parsing generic text is not something that Swift is good at.

NSString has a rich set of APIs for those tasks (NSScanner, NSRegularExpression, and all the rangeOfString... methods). Swift has pretty much nothing. (There is firstIndex(of:), but as far as I can see there is no way to find the next index, which makes it pretty much useless for most parsing tasks)

Maybe the problem is that I'm just not familiar enough with Swifts String, but until now every time I've had to work with Strings I became very frustrated.

Re:Custom string delimiters in Swift 5 by tinus_hn on Friday December 28, 2018 @03:38PM (#18779234)
I would strongly suggest that you don’t write a parser for .csv yourself, it’s a terrible format.