On 4/8/13 6:45 AM, Heri Sim wrote:
Thanks Patrick for the great explanation.
Where can I find the typical usage examples of the select operation in
the pipes module?
http://static.rust-lang.org/doc/core/pipes.html#function-select2
I guess what remains is the inference for dynamic calls on polymorphic
data structures. How would you implement a binary search tree cleanly,
with types for empty, leaf, parent nodes?
Not quite sure what you're asking, but the data type definition looks
like this:
enum Node<T> {
Empty,
Leaf(T),
Parent(@Node<T>, @Node<T>),
}
This would be the typical definition. This gives you something similar
to the data model in Erlang or ML: the garbage collector is used to
collect nodes, and sending such a binary search tree from task to task
would require a deep copy (via serialization).
You can also use ~ pointers, and avoid the garbage collector and the
deep copy on sending. This is how strcat's treemap library in core
works. But this requires explicit use of lifetimes.
What is your team's approach to corner cases? Generic syntax must cater
for corner cases? Or corner cases should have special syntax? Do more
most of the time, or do more sometimes?
There's no hard and fast rule in language design for corner cases, but
we try to minimize corner cases that violate the principle of least
surprise.
Patrick
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev