"At least three things are super weird here" What was the third thing??
Should small Rust structs be passed by-copy or by-borrow?
111–115 of 115 posts
Re: Should small Rust structs be passed by-copy or by-borrow?
#112Earlier quoted context omitted.
> a) the language designers decided to cram several paradigms into it, including a heavier than usual dose of functional. Rust is actually really close to JavaScript in that regard, with its mix of OOP-without-inheritance and the whole collection of functional method on Arrays and iterators ( map , reduce , etc.). And while People have a ton of complain about JavaScript, none of them is «the JavaScript language is to…
> What ? Do you mean “ not coming from the C language family”? Because its syntax is clearly in the C-family (semicolon, braces). My guess is that they're talking about the syntax inspired from its ML roots, like `let/let mut`, `->` for return types, and `:` for type annotations. I personally prefer these to the C-style equivalents, but I've talked with enough people who haven't used an ML-like language that I'm not…
Re: Should small Rust structs be passed by-copy or by-borrow?
#113Earlier quoted context omitted.
That's interesting, and a bit surprising. I know Ada does this, but it's explicit about only specifying semantics ("in, "out" or "in out") and letting the compiler decide. Surely C or C++ optimizers won't do this?
Let's disregard inlining etc, so that we have actual function calls in both languages. C and Rust compilers do the same thing - they follow a calling convention. It will tell you how to pass a struct, if it should be passed as a pointer or in registers etc.
Re: Should small Rust structs be passed by-copy or by-borrow?
#114Earlier quoted context omitted.
Let's disregard inlining etc, so that we have actual function calls in both languages. C and Rust compilers do the same thing - they follow a calling convention. It will tell you how to pass a struct, if it should be passed as a pointer or in registers etc.
Rust doesn't have a defined, standardized, binary calling convention, to the extent that C does.
Re: Should small Rust structs be passed by-copy or by-borrow?
#115Earlier quoted context omitted.
Rust doesn't have a defined, standardized, binary calling convention, to the extent that C does.
I agree, but that doesn't mean that it picks different calling conventions for each function call it compiles or something like that. Each version & platform of Rustc will have a calling convention that it sticks to when compiling function calls.