Giter VIP home page Giter VIP logo

Comments (8)

lpil avatar lpil commented on September 15, 2024 1

Let's use the name "update" after this has been actioned: #570

from stdlib.

inoas avatar inoas commented on September 15, 2024

OCaml's stdlib calls this update
OCaml's Base (stdlib replacement) calls this change
Haskell's containers calls this alter
Elixir's Map has get_and_update

OT: Reminds me of gleam-lang/gleam#1645
Maybe that idea could include an optional explanation why that alias exists, e.g. "similar to elixir get_and_update" or "reimplements ocaml update"

from stdlib.

mooreryan avatar mooreryan commented on September 15, 2024

#570 has the update function becoming something like this:

dict.update return Result and Error if no key found

Which does make sense if the current update is renamed to upsert imo, given the sql naming of update/upsert. Whereas this function would need some other name.

from stdlib.

inoas avatar inoas commented on September 15, 2024

I have re-read your proposal and AFAIU it now, change works on dicts with keys that can exist or not exist and depending if they exist or do not exist they can handle those cases by injecting values or even removing values if a key existed all depending on the apply function of the change call? I hope I got it.

I think update does not communicate that, update does not communicate that something is removed. alter or change communicate that something could be removed. Now that we have upsert I am in favour of alter over change but that's just me.

from stdlib.

lpil avatar lpil commented on September 15, 2024

Closing this to track in the other issue. Thanks folks!

from stdlib.

inoas avatar inoas commented on September 15, 2024

@mooreryan is this the impl you meant? #659

from stdlib.

mooreryan avatar mooreryan commented on September 15, 2024

@mooreryan is this the impl you meant? #659

Looks like it, though I don't think that the function in that pull request should be called update. The callback in that PR is also returning a Result--that would not be my preference, however, I don't have a strong opinion about that aspect.

from stdlib.

inoas avatar inoas commented on September 15, 2024

I think the general policy is that we do not return Option.
I agree that it should be called change.

from stdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.