On Fri, Oct 16, 2015 at 9:20 AM, Martin Thomson <m...@mozilla.com> wrote:
> On Fri, Oct 16, 2015 at 6:39 AM, Boris Zbarsky <bzbar...@mit.edu> wrote:
>> You should _especially_ not create attributes of type Date.
>
>
> Well, that's interesting.  I think that I might have to eat crow:
> https://github.com/w3c/webrtc-pc/issues/324
>
> I didn't read all the discussion, but what is wrong with treating Date
> as a primitive type that happens to have methods?  I know that it
> likely sucks to have all that custom code, but I've seen worse.

The problem is that they are mutable objects, with no way to make them
immutable.

So you can do:

file.lastModifiedDate.setYear(3015);

Which means that any other consumers will now see the "wrong" date.
And if you change the attribute getter to return a new Date object
each time, then

file.lastModifiedDate == file.lastModifiedDate;

returns false which is surprising.

/ Jonas
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to