Comment

Comment by metalgearsolid

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.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton