3 ms·
Using () doesn't work without introducing yet more concepts to the language, to make both let element: i32 = some_integer_array(i); let reference: &i32 = &
by dbaupp 12y ago
Using () doesn't work without introducing yet more concepts to the language, to make both
let element: i32 = some_integer_array(i);
let reference: &i32 = &some_integer_array(i);
work. In particular, the second one should give a reference to the element inside the array. I believe Scala doesn't have to deal with this subtlety, since everything is a pointer and generally the precise location of things in memory isn't so important.
This issue is definitely not insurmountable, but it is also definitely not a simple direct replacement.
- frowaway001 12y agosome_integer_array.at(i)
- dbaupp 12y agoHas the same problem, we can't support the syntax: let integer: i32 = some_integer_array.at(i); let reference: &i32 = &some_integer_array.at(i); with the desired semantics, without introducing new language concepts. In any case, we did use methods for indexing vectors for a while and it was quite annoying; the shorter syntax is nice.
- frowaway001 12y agoI don't think you are getting it.
- scott_s 12y agoFor the record, dbaupp is on the core team for Rust. But can you explain it to me? Because his explanation makes sense to me: they can't support that syntax, including getting references, without introducing new concepts. How does what your proposing get around introducing those new concepts?
- frowaway001 12y agoFor the record, Rasmus Lerdorf is on the core team for PHP. When I said "some_integer_array.at(i)" I certainly didn't mean "rename both things". Alternatively, having one additional magic kind/trait/... to denote "addressable" would be more manageable than shoe-horning things into the language's syntax which can – at this change – not be fixed anymore.
- dbaupp 12y agoYes, I'm absolutely not getting it. You're also not explaining it.
- deleted 12y ago[deleted]