Hello rust-dev,

I imagine there are reasons I've not considered for why proc
declaration syntax is the way it is, but I couldn't find any
discussion on this list or in the issues so thought I'd make a
proposal.

I think it would be nice if procs and closures had a more similar syntax.
Specifically I'd like to see proc loose it's function like ()
parameter list and gain the block like || params list as closures
have.

So rather than the current:
spawn(proc(x,y) { /* Do some work. */  });

We would write:
spawn(proc |x,y| { /* Do some work. */  });

A minor change, for sure, but I find the later easier to visually
parse and recognize as a closure. With the current syntax I find that
for a split second it looks to me like a function call to some
function "proc" with a block after it.
I thought for a moment that maybe proc was a function with a
final hidden block argument and that this was a magic syntactic sugar
for giving this "proc" function a block (kind of like the old do
syntax) but then I read the parser and learned that proc is in fact part
of the syntax.

There are probably some caveats that I haven't considered since I'm not
100% familiar with all of the closure types. If there is a glaring
reason why this is a bad idea please do tell; else let's discuss.

Thanks for reading!
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to