Rust and semantic overload

A discussion on Rust and readability made me wonder why I feel weirded out by some of the code. I went to browse hyper‘s github and stared at:

pub fn new(mut stream: &'a mut (Reader + 'a), addr: SocketAddr) -> HttpResult<Request<'a>> {

There’s hardly anything more common than a two-arguments method, yet somehow it felt (to someone coming from dynamic languages) a bit like code golf. My particular issue was that the explicitness adds a lot of semas to the declaration:

“Public function new, with arguments: stream, which is a mutable borrowed reference with the ‘a lifetime and contains a Reader plus the ‘a lifetime; and addr, which is a SocketAddr, and must return a HttpResult of type Request with lifetime ‘a.”

That’s definitely a lot of different things to say in a single sentence. And then, if I’m not looking directly at it, the line doesn’t have the typical shape of anything because it has so many components.

Writing it in multiple lines makes a huge difference for me:

pub fn new
    mut stream: &'a mut (Reader + 'a),
    addr: SocketAddr
-> HttpResult<Request<'a>> {

It looks a bit unorthodox for a function declaration — but then, with all the explicitness, a declaration in Rust practically comes with half a docblock included, so it’s not really an outraging “waste of lines”.

I still kind of wish mutability wasn’t indicated with a separate term, but sigil soup isn’t all that desirable either.

Return types on PHP 7 voted (again)

A new vote on return types is ongoing.

Differences from Past RFCs

This proposal differs from past RFCs in several key ways:

The return type is positioned after the parameter list. See Position of Type Declaration for more information about this decision.
We keep the current type options. Past proposals have suggested new types such as void, int, string or scalar; this RFC does not include any new types. Note that it does allow self and parent to be used as return types.
We keep the current search patterns. You can still search for function foo to find foo’s definition; all previous RFCs broke this common workflow.
We allow return type declarations on all function types. Will Fitch’s proposal suggested that we allow it for methods only.
We do not modify or add keywords. Past RFCs have proposed new keywords such as nullable and more. We still require the function keyword.

Discussion on Reddit.