Re:Announcing Dart 2 Stable and the Dart Web Platform
by foldr on Tuesday August 07, 2018 @01:07PM
(#17708423)
Pointers are certainly types in Rust, and although it's of course true that the Any trait is not itself a type, a reference to an Any trait (which is what you'd actually pass around) is a type.
[ Parent
| on HN ]
Re:Announcing Dart 2 Stable and the Dart Web Platform
by EugeneOZ on Tuesday August 07, 2018 @01:15PM
(#17708501)
Well, you can repeat it many times but it will not become true. I gave you link to the list of Rust types. Pointers are pointers, not types. Traits can have any name, their names mean nothing.
Re:Announcing Dart 2 Stable and the Dart Web Platform
by foldr on Tuesday August 07, 2018 @01:22PM
(#17708571)
https://doc.rust-lang.org/book/first-edition/raw-pointers.ht...
*const u32
(for example) is a clearly a Rust type -- a const pointer to an unsigned 32-bit integer, analogous to const uint32_t *p
in C/C++.I'm not sure what you mean about trait names. The purpose of the Any trait is to make it possible to pass around values of any type and dynamically downcast them, as the documentation indicates. That is a safe analogue of casting a void pointer to another type.
Re:Announcing Dart 2 Stable and the Dart Web Platform
by EugeneOZ on Tuesday August 07, 2018 @01:43PM
(#17708767)
To be dynamic, "Any" should be able to represent literally ANY type. As you can find, Any is a reflection-wise trait to work with static types. It's not something what you can use when you don't know type and language will dynamically convert it. You can't write
fn example(foo: Any) -> u32 {
foo+55
}
as you CAN do in dynamic languages.
Do you understand me now? Or we will keep talking about unsafe extra special types?
Re:Announcing Dart 2 Stable and the Dart Web Platform
by rhencke on Tuesday August 07, 2018 @01:52PM
(#17708851)
Please remember there's a genuine human on the other end, trying to have a respectful conversation with you.
Re:Announcing Dart 2 Stable and the Dart Web Platform
by EugeneOZ on Tuesday August 07, 2018 @02:55PM
(#17709485)
Or there is a person who is trying to prove his offtopic point by some pedantic interruptions, which are far from the main idea of discussion.
Re:Announcing Dart 2 Stable and the Dart Web Platform
by foldr on Tuesday August 07, 2018 @01:52PM
(#17708854)
You can do that if you change it to &Any and then downcast. See the docs for examples. If the issue is that you have to downcast, then your initial claim that Rust lacks void pointers was irrelevant even if true, since you also have to downcast a void pointer in C before you can perform operations on the type that it's actually pointing to.
Re:Announcing Dart 2 Stable and the Dart Web Platform
by xfer on Tuesday August 07, 2018 @03:34PM
(#17709831)
You can't downcast it to anything you want, it returns an Option, void pointers in C are not certainly the same, it's unsafe.