Hi,

coersion still can break any code depending on library really badly. Just suppose the method implemented for Hello in the following example was added later. After the change, different function is called. IMO, the risks from glob imports are no worse than this.

struct Hello {
  s : ~str
}

impl Hello {
  // added later
  fn print(&self) { println!("{}", self.s); }
}

trait Printable {
  fn print(&self);
}

impl Printable for Hello {
  fn print(&self) { println!("Hello world from trait"); }
}

fn main() {
  let h = Hello {s : ~"Hello world"};
  h.print(); // calling different function
}

J

On 03/12/2014 08:17 PM, Bob Ippolito wrote:
Glob imports work well up front but aren't good for maintenance. In
Haskell if a popular library adds a new function it could easily break
any packages that depend on it that use glob imports. It's more work but
almost always best to explicitly import individual names. A tool could
help with this though.

On Wednesday, March 12, 2014, Huon Wilson <dbau...@gmail.com
<mailto:dbau...@gmail.com>> wrote:

    Certain aspects of them dramatically complicate the name resolution
    algorithm (as I understand it), and, anyway, they have various
    downsides for the actual code, e.g. the equivalent in Python is
    frowned upon:
    
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#importing

    Maybe they aren't so bad in a compiled & statically typed language?
    I don't know; either way, I personally find code without glob
    imports easier to read, because I can work out which function is
    being called very easily, whereas glob imports require more effort.


    Huon

    On 12/03/14 20:44, Liigo Zhuang wrote:
    "glob use" just make compiler loading more types, but make
    programmers a lot easy (to write, to remember). perhaps I'm wrong?
    thank you!

    --
    by *Liigo*, http://blog.csdn.net/liigo/
    Google+ https://plus.google.com/105597640837742873343/


    _______________________________________________
    Rust-dev mailing list
    Rust-dev@mozilla.org  <javascript:_e(%7B%7D,'cvml','Rust-dev@mozilla.org');>
    https://mail.mozilla.org/listinfo/rust-dev



_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to