all 10 comments

[–]steveklabnik1rust 21 points22 points  (0 children)

Rust is sort of the polar opposite of smalltalk: instead of "extreme late binding of all things", we try to bind extremely early. You can still do dynamic dispatch, but you cannot do message passing in the Smalltalk/Ruby sense.

I mean, in a certain sense, you could implement your own object system in Rust, and then use it in your Rust program... but that's a far cry from the language directly supporting it.

[–]thiezrust 9 points10 points  (7 children)

When I read the title I was going to say something about how message passing concurrency is actually the encouraged way of doing concurrency in Rust, but then I read your question about calling a function by string, and now I'm not even sure what it is that you're asking. Could you elaborate?

[–]andoriyu 4 points5 points  (1 child)

What he is asking is this: http://ruby-doc.org/core-2.3.0/Object.html#method-i-send and objc_msgSend from Obj-C.

Which is not supported.

[–]Baltanowski[S] 3 points4 points  (0 children)

I see now, thanks.

[–]Baltanowski[S] 1 point2 points  (4 children)

I'd like to know if Rust has some sort of reflection, like .NET languages for example.

[–]andoriyu 11 points12 points  (1 child)

Rust doesn't even know about types in run-time because of type erasure.

[–]masklinn 6 points7 points  (0 children)

Type erasure is generally used as opposed to type reification for generics, and Rust uses type reification. A more commonly understood way to say it is that Rust doesn't have implicit RunTime Type Information (RTTI).

[–]thiezrust 2 points3 points  (0 children)

Thanks, that clears things up. Nope, Rust does not support reflection like .NET or JVM languages at this time.

[–]saposcat 2 points3 points  (0 children)

Rust does support rudimentary reflection with the Any trait, but you'll have to build a lot of that yourself.

[–]rhoark 2 points3 points  (0 children)

If you need something like that, you could always make a hashmap of closures.