Skip to content

Disallow mutating state of Blob/File objects #75

Open

Description

@annevk

In particular, I think we should no longer add something like close() and make that an invariant of these objects.

That way there's no longer a need for defensive cloning (through serializing/deserializing) of these objects, which helps with whatwg/url#277.

Making a note of this somewhere in the document seems sufficient.

Activity

  1. mkruisselbrink commented on Mar 31, 2017

    @mkruisselbrink
    Collaborator

    I agree that defining Blob/File as fully immutable (which they more or less already are currently) would definitely be a nice thing. I'm not sure if we can really get rid of defensive cloning though. For example reading a File can always cause a NotReadableError if the snapshot state of the File no longer matches the state of the underlying storage (although the whole concept of this snapshot state isn't defined very well. I don't think we want to start requiring user agents to actually do defensive cloning themselves every time they create a File).

  2. annevk commented on Apr 2, 2017

    @annevk
    MemberAuthor

    Defensive cloning doesn't help with snapshot state I think, since we wouldn't want to require cloning to copy the bytes, cloning should just copy a pointer.

  3. mkruisselbrink commented on Apr 3, 2017

    @mkruisselbrink
    Collaborator

    Ah yes, good point. So yeah, I should definitely add a note somewhere to make it explicit that blob's are immutable, noting that the snapshot state might still cause the same operation on the same blob to behave differently at different times.

  4. andrew-aladev commented on Apr 8, 2019

    @andrew-aladev

    I agree that defining Blob/File as fully immutable (which they more or less already are currently) would definitely be a nice thing.

    I don't think so. You like functional programming. You just forgot that you are making API for whole Earth. Some people don't like it. Why do you think that you can force your programming style?

  5. andrew-aladev commented on Apr 8, 2019

    @andrew-aladev

    In particular, I think we should no longer add something like close() and make that an invariant of these objects.

    If you don't want to maintain blob/file state inside - people will have to invent their own bicycle wrapper that does this (with some method like toNative()). If you are going to make user applications more error prone - you are doing fine job.

  6. guest271314 commented on Apr 8, 2019

    @guest271314

    @andrew-aladev If toNative() only sets the name property of the File object FormData set() method can be utilized #126 (comment)

  7. added 2 commits that reference this issue on May 21, 2020
    40f442d
    030d980
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions