Re: [rust-dev] Structural Typing

2014-03-23 Thread Daniel Micay
On 23/03/14 06:34 AM, Ziad Hatahet wrote: Hi all, Are there any plans to implement structural typing in Rust? Something like this Scala code: http://en.wikipedia.org/wiki/Duck_typing#In_Scala Rust used to have structural records. The feature was removed because it's far from orthogonal with

Re: [rust-dev] Structural Typing

2014-03-23 Thread Liigo Zhuang
IMO, this is bad. 2014年3月23日 下午6:34于 Ziad Hatahet hata...@gmail.com写道: Hi all, Are there any plans to implement structural typing in Rust? Something like this Scala code: http://en.wikipedia.org/wiki/Duck_typing#In_Scala ___ Rust-dev mailing

Re: [rust-dev] Structural Typing

2014-03-23 Thread Matthieu Monrocq
I would note that Rust macros are actually working with structural typing: the expanded macro cannot be compiled unless the expressions/statements it results in can be compiled. Regarding Scala here, it seems a weird idea to ask that each and every method should copy+paste the interface. We all

Re: [rust-dev] Structural Typing

2014-03-23 Thread Ziad Hatahet
You wouldn't probably use this for each and every method, but what it gives you is Go-style duck typing. Sure you can define a trait, but what if the struct you to pass to your function does not implement it? I guess you would have to implement a wrapper around it manually then. -- Ziad On

Re: [rust-dev] Structural Typing

2014-03-23 Thread Patrick Walton
On 3/23/14 2:19 PM, Ziad Hatahet wrote: You wouldn't probably use this for each and every method, but what it gives you is Go-style duck typing. Sure you can define a trait, but what if the struct you to pass to your function does not implement it? I guess you would have to implement a wrapper

Re: [rust-dev] Structural Typing

2014-03-23 Thread Liigo Zhuang
+1 2014年3月24日 上午5:46于 Patrick Walton pcwal...@mozilla.com写道: On 3/23/14 2:19 PM, Ziad Hatahet wrote: You wouldn't probably use this for each and every method, but what it gives you is Go-style duck typing. Sure you can define a trait, but what if the struct you to pass to your function

Re: [rust-dev] Structural Typing

2014-03-23 Thread Ziad Hatahet
Thanks for the feedback everyone. It makes sense how things currently are for Rust. Keep up the great work! -- Ziad On Sun, Mar 23, 2014 at 4:54 PM, Liigo Zhuang com.li...@gmail.com wrote: +1 2014年3月24日 上午5:46于 Patrick Walton pcwal...@mozilla.com写道: On 3/23/14 2:19 PM, Ziad Hatahet wrote: