News for hackers. Stuff that matters.
Re:What’s New in Swift 5.2 by metalgearsolid on Thursday February 06, 2020 @02:46PM (#22259573)
I'm pretty apprehensive about this "callAsFunction()" feature. Requiring users to name things in a specific way was the kind of awful UX our customers struggled with when using our hobbled-together marketing software.

IMO, some better alternatives, in order of personal preference:

* Give away the functionality to all types that implement only a single function.

* Require an explicit protocol conformance. I get that the language does not want features to be hidden away, but requiring a user to implement a function with a specific name and signature is literally the job of a protocol. It doesn't seem like much of a hurdle for non-beginners, who have likely been familiarized with core protocols like Sequence or Collection, to acquire a knowledge of a CallAsFunction protocol.

* Introduce a new keyword, or tag (like @implicit).

* Allow the user to unlock the functionality through a more obscure phrasing. Even something as ugly as "func ` `()" could be preferable.

Re:What’s New in Swift 5.2 by mantap on Thursday February 06, 2020 @11:30PM (#22263225)
There is a danger of overengineering. This is a feature that will only be used in rare situations. So it doesn't really matter that it's just a magic identifier. As long as you aren't likely to use it by accident... I'm assuming they checked GitHub that nobody has named anything callAsFunction before choosing it
Re:What’s New in Swift 5.2 by smabie on Friday February 07, 2020 @07:55AM (#22265479)
Apply on objects is used constantly in Scala, why would it be different in Swift?