@hydroper Could you say more about what this syntax would be used for? Perhaps a comparison between current rust and the proposed syntax might help illustrate the concept better.
with exists in some variations of Pascal and JavaScript. IDK about Pascal, but in JavaScript it’s considered an antipattern (and, in my opinion, rightfully so). The reason: it prevents local reasoning by introducing implicit context into the source (which needs to manifest as statefulness in the reader’s mind).
From what I can tell, your examples could be solved with the struct update syntax, although I’m not sure – you didn’t really specify very clearly what exactly your variant of “with” is supposed do.
Here is a link to the Moonscript reference on with statements,this is the language in the example from the first comment.
I am not convinced that Rust needs with statements since they can be emulated very easily,both with the code in my previous comment,and using the tap crate
That’s true. Also, it’s not hard to use block expressions to do the same thing anonymously, i.e., invite({ let p = Person::new(); p.rant = 300 * km; p.purple = .333; p });…