You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think flatten should be polymorphic on sequences and objects. On sequences
seq.flatten() = seq.map(r.row.flatten())
On objects:
obj.flatten(...) = obj.map_merge(...)
As to what specific arguments flatten accepts and what it does with them, I think you're roughly correct, but we still have to work out what to do with pluck. But basically, the whole thing is sugar for merge.
So polymorphism here seems very inconsistent with how we do pick and pluck.Pick and pluck are the same operation but one is for an object while the other is for a sequence of objects. I feel fairly strongly that we should either have both of these be polymorphic or neither.
I'm in favor of making them polymorphic and I remember we argued about this at one point and judging by our current solution the other side won. Does anyone remember what the arguments were, @coffeemug I feel like you were the main opponent of polymorphism for pluck and pick but I could be misremembering.
The pick and pluck duality is going away -- we're going to use pluck for both. In fact, in the new language as many things as possible will be polymorphic -- whenever something is defined on an object, whenever possible it will also be defined as a map over a stream.
We couldn't do it before because of the type system, but now that it's gone, we can make everything polymorphic on objects and streams and use the same name without confusing users.
Also, I think that in the new language we should define pick as follows (it would of course also be polymorphic on streams):
We're sort of conflating keyword and library function here. I don't know of any language in which it's a try keyword (I don't know many languages though) but I think it's a builtin function in a lot. In most cases I think we'll be fine because it's normally a method on a dict object while we'd have it being a method on an ast object.
However I do have some concern that values has a different meaning in some languages than we're giving it here. In python
{"a" : 1, "b" : 2}.values() == ["a", "b"]
Ruby behaves the same but has a values_at method which is the same as what we're describing.
Activity
jdoliner commentedon Feb 13, 2013
Just to make sure I understand, flatten is sugar for:
I think this is a very intuitive meaning for flatten. And flatten can also take arguments which is equivalent to:
coffeemug commentedon Feb 13, 2013
I think
flattenshould be polymorphic on sequences and objects. On sequencesOn objects:
As to what specific arguments
flattenaccepts and what it does with them, I think you're roughly correct, but we still have to work out what to do with pluck. But basically, the whole thing is sugar formerge.jdoliner commentedon Feb 13, 2013
So polymorphism here seems very inconsistent with how we do
pickandpluck.Pickandpluckare the same operation but one is for an object while the other is for a sequence of objects. I feel fairly strongly that we should either have both of these be polymorphic or neither.I'm in favor of making them polymorphic and I remember we argued about this at one point and judging by our current solution the other side won. Does anyone remember what the arguments were, @coffeemug I feel like you were the main opponent of polymorphism for pluck and pick but I could be misremembering.
coffeemug commentedon Feb 13, 2013
The
pickandpluckduality is going away -- we're going to usepluckfor both. In fact, in the new language as many things as possible will be polymorphic -- whenever something is defined on an object, whenever possible it will also be defined as a map over a stream.We couldn't do it before because of the type system, but now that it's gone, we can make everything polymorphic on objects and streams and use the same name without confusing users.
Also, I think that in the new language we should define
pickas follows (it would of course also be polymorphic on streams):al3xandru commentedon Feb 14, 2013
I think in PL this operation (named here
pick) applied to dict/hash/etc is calledvalues.coffeemug commentedon Feb 14, 2013
valuesis cool, though it would be hard to use because of its inherent keywordness.al3xandru commentedon Feb 14, 2013
Where is
valuesa keyword?coffeemug commentedon Feb 14, 2013
I could have sworn it's a keyword in Python, but upon checking, it isn't.
jdoliner commentedon Feb 14, 2013
We're sort of conflating keyword and library function here. I don't know of any language in which it's a try keyword (I don't know many languages though) but I think it's a builtin function in a lot. In most cases I think we'll be fine because it's normally a method on a dict object while we'd have it being a method on an ast object.
However I do have some concern that values has a different meaning in some languages than we're giving it here. In python
Ruby behaves the same but has a
values_atmethod which is the same as what we're describing.How do we feel about
values_of?al3xandru commentedon Feb 14, 2013
@jdoliner: in case you are not using a different Python than mine, this is not true:
Same in Ruby.
jdoliner commentedon Feb 14, 2013
Whoops, sorry I did the behavior of
keysthere.Valuesis as you describe.coffeemug commentedon Jan 14, 2014
Closing in favor of #1855.
sunjay commentedon Apr 28, 2016
Note that this is still referenced in the docs here: https://rethinkdb.com/docs/table-joins/
Given that this has been superseded by a new issue and given that the new issue is on the backlog that should probably be updated.