Re: [rust-dev] Class UI

2012-04-14 Thread Kosta Welke
On Apr 10, 2012, at 9:26 PM, Masklinn wrote: I was reading http://smallcultfollowing.com/babysteps/blog/2012/04/09/rusts-object-system/ today, and saw the description of the classes definition. Next to it, Nicholas notes: I am not fond of the definition of constructors, in particular I

Re: [rust-dev] Class UI

2012-04-12 Thread Kobi Lurie
what about a private new() in the class, that returns the allocated instance, and a public 'make' fn, with how many overloads you want, to serve as a ctor. rustc can require that atleast one 'make' fn will exist for a class, and that it returns the same object that came from new(). (the user

Re: [rust-dev] Class UI

2012-04-12 Thread Niko Matsakis
In fact, Rust separates initialization from allocation. The OP was correct that new might better be called an initializer, but I think that ship has sailed---constructor is the generally accepted term for the function which initiailizes the instance, for better or worse. Still, for a class

Re: [rust-dev] Class UI

2012-04-12 Thread Benjamin Striegel
Optional named parameters in function invocations could be a third option, although of course that introduces a third inflexibility to consider. :P So, which happens most often? 1) You create a class without any constructor besides property assignment, and then later introduce a more substantial

Re: [rust-dev] Class UI

2012-04-12 Thread Niko Matsakis
On 4/12/12 7:45 AM, Benjamin Striegel wrote: Optional named parameters in function invocations could be a third option, although of course that introduces a third inflexibility to consider. :P So, which happens most often? I suppose it's not only a question of what happens most often, but

Re: [rust-dev] Class UI

2012-04-12 Thread Joe Groff
On Thu, Apr 12, 2012 at 11:54 AM, Niko Matsakis n...@alum.mit.edu wrote: You would then create an instance of C using `C::create(...)`. The only thing I am not sure about is how one declares the construction to be private? Have you guys read Bob Nystrom's notes about designing a safe

Re: [rust-dev] Class UI

2012-04-12 Thread Niko Matsakis
Based on a quick read, this sounds almost identical to what I proposed, except that `construct()` would be the literal syntax. Looks like a neat blog, thanks for the tip. Niko On 4/12/12 12:03 PM, Joe Groff wrote: On Thu, Apr 12, 2012 at 11:54 AM, Niko Matsakisn...@alum.mit.edu wrote:

[rust-dev] Class UI

2012-04-11 Thread Masklinn
I was reading http://smallcultfollowing.com/babysteps/blog/2012/04/09/rusts-object-system/ today, and saw the description of the classes definition. Next to it, Nicholas notes: I am not fond of the definition of constructors, in particular I can only agree, for a simple reason: the example is

Re: [rust-dev] Class UI

2012-04-11 Thread Steven Blenkinsop
I don't know about your use of the term constructor, but it is true that new is often associated with the allocation side of things instead of the initialization side of things in languages that make a distinction (many don't). Go faces the opposite problem since people think of new as syntax for