On 02/08/2012 12:51 PM, Emmanuel Surleau wrote:
Hi,
I'm new to rust, and I'm struggling to find an elegant way to work with default
parameters.
We don't have explicit support for it yet. Nor named params, varargs, or
generalized overloading (we only allow overloading via traits).
There is room in the syntax and semantics for this in the future, but I
agree with Patrick that running experiments on combining such features
is past scope for the "stabilize for 1.0" roadmap; we already have a
_very_ full plate and have been trying to get the language to stop
moving for two years now. It's slowing but we're trying to
cut-in-order-to-ship pretty aggressively. This subset of features is
comparatively non-essential (lots of language lack it) and can be worked
around several ways, as people have suggested:
1. pass option<foo> and the callers can say 'none' for defaults.
2. make a separate default-passing fn
3. use a method-chaining "fluent interface" approach if you want
the type system to help you enforce that only certain combinations
of arguments are legit
4. use a macro
5. overload via traits
If none of these fit the bill, well, we might explore the space we left
open for this in the future. I won't close a bug on it or anything, it's
a legit feature. Just not one I'm going to want to pull into the
language this time around.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev