Re: Add REMOVE to map put/nested_put (maybe?)

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
mattlewis said...

I don't like nested_transform. I prefer nested_put, since it matches put. We'd have to change put to transform, which doesn't sound right.

Why? I don't see why nested_transform() can just call put()/nested_put() when it needs to, and call a remove function the other times. (Of course, that's significantly less elegant than just nested_put(REMOVE).)

If you want to do some operation in a nested map, at some point you'll want to do that operation in a non-nested map. This is a slightly different operation than what we already have, but creating a new function would seem confusing to me. I know I'd always have to look at the docs to figure out which operations go with which function.

The "put" metaphor isn't quite so clean any more, but I think that's better than adding to the interface.

jimcbrown said...
mattlewis said...

I think the solution is to enhance put / nested_put (which implementation actually calls put) with some additional operations.

Does put() do a REMOVE already? How is that done currently?

Currently, to do what Greg is talking about, you would have to get the value, remove whatever you wanted to remove from the value and then put it back to replace what was there. The only sort of removal currently done by the library is to remove an entire entry.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu