Giter VIP home page Giter VIP logo

Comments (6)

AlexKnauth avatar AlexKnauth commented on July 19, 2024

Or, does the argument order of lens-set* and lens-transform* make more sense? (target first, then lens, then new-value/transformer-function)

It breaks the convention of having the lens as the first argument, but allows the lens and the new-value/transformer-function to be next to each other, and is more consistent with hash-set, hash-update, and other similar functions.

from lens.

jackfirth avatar jackfirth commented on July 19, 2024

I'm not sure how to fold plurality into argument conventions, because there's several plural cases:

  • Multiple lenses, one target, one view (lens-view*)
  • Multiple lenses, one target, multiple views (lens-transform*, lens-set*)
  • One lens, multiple targets, one view (possibly something like lens-set-all, lens-transform-all)
  • One lens, multiple targets, multiple views (possibly something like lens-set-each, lens-transform-each)
  • Multiple lenses, multiple targets, one view (possibly something like lens-set-all for multiple lenses)

And probably more I haven't thought of. The singular lens-view couldn't be both consistent with a function that takes multiple lenses and a function that takes multiple views if variable-arity functions are desired and the rest arguments are uniform.

from lens.

AlexKnauth avatar AlexKnauth commented on July 19, 2024

Well, right now, the argument orders for the single-lens cases of lens-view*, lens-set* and lens-transform* are consistent with each other and consistent with functions like hash-ref, hash-set, and hash-update.

If you thought it would make more sense, you could change all of them to follow that convention, but that breaks the convention of having the lens as the first argument, and also turns it into a postfix-ish feel.

I'm not sure what you mean by lens-view being consistent with a function that takes multiple views though?

from lens.

jackfirth avatar jackfirth commented on July 19, 2024

I meant lens-set, my apologies.

from lens.

AlexKnauth avatar AlexKnauth commented on July 19, 2024

Maybe worth noting: For the plural of lens-set, I debated between two possibilities:

  • (lens-set* target lens ... new-val), equivalent to (lens-set (lens-thrush lens ...) target new-val)
  • (lens-set* target lens new-val ... ...), equivalent to (for/fold ([target target]) ([lens/val (in-slice 2 ....)]) (lens-set lens target val)), filling in the gaps.

I chose the second one because I thought it would be more useful, especially since it's easy to throw a lens-thrush in there for the first one, and also because the second would be consistent with hash-set*.

from lens.

jackfirth avatar jackfirth commented on July 19, 2024

Let's move general discussion of argument order to #73

from lens.

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.