-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename fmt::Default
to fmt::Format
#11298
Conversation
Ok, it seems the use of a free function for |
I'm having second thoughts about this again, which I guess was a little inevitable. I very much like the name
I'm still a little uneasy about this reasoning (as I was before). I'd ideally like to discuss this further to figure out how to keep the name |
Why not copy Haskell here and call it Show or even Display. |
This is in preparation for adding a `#[deriving(Format)]` and removing the `ToStr` trait, as discussed in rust-lang#9806.
Ok, removed the |
@metajack Because it needs to be consistent with the naming convention of the other format traits. @alexcrichton I agree with your reasoning. It is a shame we can't have paths in deriving. Then you could have: use std::fmt;
#[deriving(fmt::Default)]
struct MyStruct; The global-ness and hard-wiredness of deriving trait names is as concerning as it is with macro identifiers. Won't this also be an issue once we allow clients to create their own deriving implementations? What happens when you have two crates that implement deriving for two different traits of the same name? |
That's a good point re user-implementable deriving; it would be nicer to be able to register a deriving mode for a specific trait (say #[deriving(::foo::bar::Trait)] struct Struct;
use foo;
#[deriving(foo::bar::Trait)] struct Struct;
use foo::bar;
#[deriving(bar::Trait)] struct Struct;
use foo::bar::Trait;
#[deriving(Trait)] struct Struct;
use new_name = foo::bar;
#[deriving(new_name::Trait)] struct Struct; but, |
Needs a rebase. |
I'm adding this to the meeting agenda. |
We decided in today's meeting to call this trait If you're out of time, I can take over this patch as well. |
What concerns me is that this rename is not being done because I guess what I'm saying is, can we try to think of creative design solutions for deriving rather than resorting to renaming perfectly good trait names? From exchanges on IRC and @huonw's posts above it seems that this is a very challenging problem, but solving it could help syntax extensions in general - not just for deriving. |
It's a tough problem to process paths in deriving. These two mechanisms (use statements and deriving modes) operate very differently. Everything with deriving happens in the expansion phase whereas everything with use statements happens as part of the resolve phase. I suppose we could run resolve twice, but it seems like things could get complicated quickly. I think that there's two reasons for me for It is an interesting concern though about deriving essentially having a global namespace, but the question is whether to resolve the |
Ok, I'm going to close this for now. |
Yeah, it's a tricky problem. But I also worry about macros living in the global namespace too. The fact that you can't do |
This is in preparation for adding a
#[deriving(Format)]
and removing theToStr
trait, as discussed in #9806.