<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi SE,<div class=""><br class=""></div><div class="">As I’ve been using my own custom operators like “?!”, “!!”, or operators provided by libraries (<|, ~>, etc), I’ve often wanted to capture the #file and #line where the operators are used to make debugging their use a lot easier.</div><div class=""><br class=""></div><div class="">For example, given something the unwrap-or-die operator (<a href="https://github.com/erica/swift-evolution/blob/2c1be72e34c970894e4ba7ed9df5cee3298d4282/proposals/XXXX-unwrap-or-die.md" class="">https://github.com/erica/swift-evolution/blob/2c1be72e34c970894e4ba7ed9df5cee3298d4282/proposals/XXXX-unwrap-or-die.md</a>), you’d want to capture the #file and #line so you could pass it on to the underlying call to fatalError().</div><div class=""><br class=""></div><div class="">Or, if you’re using a custom bind operator and something goes wrong, it’d be great to be able to capture the file and line where the operator is used so you can quickly triage the bug in your code.</div><div class=""><br class=""></div><div class="">Unfortunately, Swift has the hard limit the the implementations of unary operators may have one-and-only-one parameter, and that binary operators may only have two parameters.</div><div class=""><br class=""></div><div class="">I’d like to propose a very minor change to Swift, whereby operator implementations may have more than their one or two parameters, provided that all subsequent parameters come with a default value. This would make it trivial to add in #file, #line, #function, etc to your operator implementations, which you can then capture for your own purposes.</div><div class=""><br class=""></div><div class="">An implementation of this change, with passing tests, can be found here: <a href="https://github.com/davedelong/swift/commit/c65c634a59b63add0dc9df1ac8803e9d70bfa697" class="">https://github.com/davedelong/swift/commit/c65c634a59b63add0dc9df1ac8803e9d70bfa697</a></div><div class=""><br class=""></div><div class="">Dave</div></body></html>