Re: about lightweight traits

2015-02-13 Thread Andrea Giammarchi
It looks like we agree traits are **not** classes so that classes should not be used or accepted as traits ... which is already an answer to my initial question. Other "problems" init is a special case, as constructor is. You don't need a constructor to create an instance, you might not need to i

Re: about lightweight traits

2015-02-12 Thread Luke Scott
> On Feb 12, 2015, at 1:13 PM, Peter Seliger > wrote: > > As for JavaScript, I strongly believe, Role based composition patterns > like Mixins or Traits should be function based. I assume by this you mean that it shouldn’t be a construct and any special keywords. If that’s the case: This can

Re: about lightweight traits

2015-02-12 Thread Peter Seliger
As for JavaScript, I strongly believe, Role based composition patterns like Mixins or Traits should be function based. Whereas the widely used purely object based approach (together with some copy mechanics provided by one of the several [extends] implementations) does still work for Mixins, it is

Re: about lightweight traits

2015-02-12 Thread Luke Scott
I know what you’re going for, and I had this in my initial implementation. The issue then becomes: If Trait2 mixes in Trait1, does the init method get replaced? Traits are about inserting functionality, not about inheritance. Example: trait Trait1 { init() { // init Trait1 } }

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
Luke, forgot one detail: you do not explicitly initialize traits, these are initialized if these have an `init` or `initialize` method defined, and before the constructor is executed. So, using you example code: ```js trait Trait1 { initt() { this.trait1Data = {what:'ever'

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
Luke, answering in order: 1. defining order, first come, first serve ... same as everything else on daily usage (events, Array of callbacks, etc) 2. You do not ever pass parameter to them, parameters are constructors matters, traits should be independent and unaware of constructors arguments othe

Re: about lightweight traits

2015-02-12 Thread Caitlin Potter
>Why does ES even need traits? >The only aspect they can help with here is the type system we don't have yet. > >We have `Object.assign` that works fantastically for most classic trait use >cases. They’d provide a way to explain WebIDL concepts like partial interfaces and partial dictionaries. T

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
...@gmail.com> wrote: > > So you are saying we can just forget about extends keyword and use mixin > instead for everything, right? > -- > From: Alex Russell > Sent: ‎12/‎02/‎2015 20:05 > To: Andrea Giammarchi > Cc: Luke Scott ; es-discuss@mozill

Re: about lightweight traits

2015-02-12 Thread Luke Scott
> On Feb 12, 2015, at 12:11 PM, Domenic Denicola wrote: > > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of > Benjamin Gruenbaum > >> We have `Object.assign` that works fantastically for most classic trait use >> cases. > > Well, actually, it works extremely poorly. The

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
n Thu, Feb 12, 2015 at 9:19 PM, Benjamin Gruenbaum wrote: > Sorry, forgot to CC the list > > *From:* Benjamin Gruenbaum > *Date:* February 12, 2015 at 22:19:14 GMT+2 > *To:* Domenic Denicola > *Subject:* *Re: about lightweight traits* > > Those points are good, let me

Re: about lightweight traits

2015-02-12 Thread Luke Scott
t; <mailto:es-discuss@mozilla.org> > Subject: Re: about lightweight traits > > Traits as class make perfect sense when you consider that classes are > functions and so are traits. > > On Thu, Feb 12, 2015 at 10:27 AM, Andrea Giammarchi > mailto:andrea.giammar...@gmail.

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
`Object.assign` is good only to define defaults properties, since it does not even understand getters and setters, it's really a poor option for anything trait related. `Object.assign` is an ES6 introduction based on ES3 assumptions, not even sure why someone would consider it for traits. Moreove

Fwd: about lightweight traits

2015-02-12 Thread Benjamin Gruenbaum
Sorry, forgot to CC the list > From: Benjamin Gruenbaum > Date: February 12, 2015 at 22:19:14 GMT+2 > To: Domenic Denicola > Subject: Re: about lightweight traits > > Those points are good, let me try to address them > > State - In other languages like C# and swi

RE: about lightweight traits

2015-02-12 Thread Domenic Denicola
From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Benjamin Gruenbaum > We have `Object.assign` that works fantastically for most classic trait use > cases. Well, actually, it works extremely poorly. The old (now dead or deferred) `Object.mixin`, once called `Object.define`,

RE: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
So you are saying we can just forget about extends keyword and use mixin instead for everything, right? -Original Message- From: "Alex Russell" Sent: ‎12/‎02/‎2015 20:05 To: "Andrea Giammarchi" Cc: "Luke Scott" ; "es-discuss@mozilla.org" Subje

Re: about lightweight traits

2015-02-12 Thread Benjamin Gruenbaum
Why does ES even need traits? The only aspect they can help with here is the type system we don't have yet. We have `Object.assign` that works fantastically for most classic trait use cases. > On Feb 12, 2015, at 18:35, Andrea Giammarchi > wrote: > > Without going down full specification/impl

Re: about lightweight traits

2015-02-12 Thread Alex Russell
Traits as class make perfect sense when you consider that classes are functions and so are traits. On Thu, Feb 12, 2015 at 10:27 AM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > this thousand times ... Traits as class makes no sense to me indeed and > Mark example shows plain objects

Re: about lightweight traits

2015-02-12 Thread Matthew Robb
When I brought this up my thoughts were to have the classes flattened to a linear inheritance model. Yeah this means an ownProp copy from the constructor for statics and the prototype for instance onto methods. That might be a limitation but currently class syntax is javascript's nicest way to desc

Re: about lightweight traits

2015-02-12 Thread Luke Scott
> On Feb 12, 2015, at 10:27 AM, Andrea Giammarchi > wrote: > > this thousand times ... Traits as class makes no sense to me indeed and Mark > example shows plain objects passed as Trait.create ... that works just fine, > except some trait initialization, which should not be a constructor, cou

Re: about lightweight traits

2015-02-12 Thread Andrea Giammarchi
this thousand times ... Traits as class makes no sense to me indeed and Mark example shows plain objects passed as Trait.create ... that works just fine, except some trait initialization, which should not be a constructor, could be used too. Is there any other language that uses same classical OOP

Re: about lightweight traits

2015-02-12 Thread Luke Scott
> On Feb 12, 2015, at 8:35 AM, Andrea Giammarchi > wrote: > > Without going down full specification/implementation details, does anyone > believe that classes should/could be used, in the future, as traits/mixins > too? > > I find that an anty pattern. > > I think traits should be just plai

Re: about lightweight traits

2015-02-12 Thread Sébastien Cevey
I would agree. How would you use classes as traits -- are you talking about multiple inheritance? Or flattened to a linear inheritance model? On 12 February 2015 at 16:35, Andrea Giammarchi wrote: > Without going down full specification/implementation details, does anyone > believe that classes

Re: about lightweight traits

2015-02-12 Thread Mark S. Miller
On Thu, Feb 12, 2015 at 8:35 AM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Without going down full specification/implementation details, does anyone > believe that classes should/could be used, in the future, as traits/mixins > too? > I do. But I am in no rush. Classes need to gro

about lightweight traits

2015-02-12 Thread Andrea Giammarchi
Without going down full specification/implementation details, does anyone believe that classes should/could be used, in the future, as traits/mixins too? I find that an anty pattern. I think traits should be just plain objects with an initializer or some special object flagged as trait and I'd ra