Thursday, 5 June 2014

Swift Pipe Forward

Update: A follow up post is now available showing how pipe can be used (Pipe and Chains!)

Just a quick one today as I'm busy contemplating on Swift exceptions (or more precisely the fact that I think it's a good idea that it doesn't appear to have them (yet?) - Good debate with +Simon Cousins  earlier in work on the subject)

Anyhow, a little bit of Swift code showing how the F# pipe forward operator, touched on earlier, can be implemented. Look closely and you'll see some currying,generics and string interpolation in action.

I'll admit I need to look more into the options available for the 'operator' keyword and associativity parameters but the setup here works quite nicely at the moment. What's not immediately apparent is that types are maintained and checked throughout, although I'm not fully convinced yet that the Swift compiler isn't bug free - it could certainly look to f# in this regards and the hover over intellisense which proves invaluable, particularly where types are inferred.

Pop over to GitHub to see full workings out


No comments:

Post a Comment