|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 - 3 - 4 | Next > |
|
|
Re: [scala-internals] Naming collection operationsincluding/excluding ?
On Mon, May 11, 2009 at 10:18 AM, martin odersky <martin.odersky@...> wrote: I have a question concerning an alternative naming for the + and - |
|
|
Re: Re: [scala-internals] Naming collection operationsMy understanding is that these methods would be available for both mutable and immutable collections, but that in both cases they would return a -new- collection with the elements added. That is, the methods won't actually mutate the mutable collection on which they're called. They'll create a new mutable collection with all the previous elements plus the additional element. The names "add" and "remove" seem to imply that the original collection will be mutated.
--j On Mon, May 11, 2009 at 11:22 AM, Nils Kilden-Pedersen <nilskp@...> wrote:
|
|
|
Re: Re: [scala-internals] Naming collection operationsOn Mon, May 11, 2009 at 2:24 PM, Jorge Ortiz <jorge.ortiz@...> wrote: My understanding is that these methods would be available for both mutable and immutable collections, but that in both cases they would return a -new- collection with the elements added. That is, the methods won't actually mutate the mutable collection on which they're called. They'll create a new mutable collection with all the previous elements plus the additional element. The names "add" and "remove" seem to imply that the original collection will be mutated. Then why wouldn't the clone methods work? |
|
|
|
|
|
Re: Re: [scala-internals] Naming collection operationsI probably misunderstood Martin's response. I was under the impression that he didn't want any of the proposals given (newWith, copyWith), but I see that his response only mentioned cloneWith.
On Mon, May 11, 2009 at 2:40 PM, Johannes Rudolph <johannes.rudolph@...> wrote:
|
|
|
Re: Re: [scala-internals] Naming collection operations+1 on plus/minus. If the names '+' and '-' are appropriate (and I think they are, for purely functional operations), then so are 'plus' and 'minus'.
I personally wouldn't mind 'mit' und 'ohne', but I lived in Bundesrepublik Deutschland for a couple of years.
|
|
|
Re: Re: [scala-internals] Naming collection operationsAll,
plus/minus works for me as does the variant plus/sans . Best wishes, --greg On Mon, May 11, 2009 at 12:52 PM, Larry Yogman <lyogman@...> wrote:
-- L.G. Meredith Managing Partner Biosimilarity LLC 1219 NW 83rd St Seattle, WA 98117 +1 206.650.3740 http://biosimilarity.blogspot.com |
|
|
Re: Re: [scala-internals] Naming collection operationsIt seems plus/minus has the relative majority of votes. Let's use that then.
Thanks for your input! -- Martin On Mon, May 11, 2009 at 10:24 PM, Meredith Gregory <lgreg.meredith@...> wrote: > All, > > plus/minus works for me as does the variant plus/sans . > > Best wishes, > > --greg > > On Mon, May 11, 2009 at 12:52 PM, Larry Yogman <lyogman@...> > wrote: >> >> +1 on plus/minus. If the names '+' and '-' are appropriate (and I think >> they >> are, for purely functional operations), then so are 'plus' and 'minus'. >> >> I personally wouldn't mind 'mit' und 'ohne', but I lived in Bundesrepublik >> Deutschland for a couple of years. >> >> >> Rob Dickens-2 wrote: >> > >> > plus/minus? >> > >> > 2009/5/11 martin odersky <martin.odersky@...> >> > >> >> On Mon, May 11, 2009 at 11:25 AM, martin odersky >> >> <martin.odersky@...> >> >> wrote: >> >> > On Mon, May 11, 2009 at 11:03 AM, Jorge Ortiz <jorge.ortiz@...> >> >> wrote: >> >> >> At the risk of method overloading, I'd suggest union/minus >> >> > >> >> ... and I really want to avoid method overloading for generic >> >> collections; in conjunction with type inference it is more dangerous >> >> than might seem at first. E.g. how do you resolve this: >> >> >> >> val s: Set[Set[String]] = Set.empty >> >> >> >> s union empty // is this Set.empty or Set(Set.empty) ? >> >> >> >> Cheers >> >> >> >> -- Martin >> >> >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Naming-collection-operations-tp23478942p23490294.html >> Sent from the Scala - Debate mailing list archive at Nabble.com. >> > > > > -- > L.G. Meredith > Managing Partner > Biosimilarity LLC > 1219 NW 83rd St > Seattle, WA 98117 > > +1 206.650.3740 > > http://biosimilarity.blogspot.com > |
|
|
Re: Re: [scala-internals] Naming collection operations2009/5/11 martin odersky <martin.odersky@...>:
> It seems plus/minus has the relative majority of votes. Let's use that then. It's a bit late for me to get in this discussion now, but I was avoiding it on the assumption that people would choose something vaguely sensible and given that the details really didn't matter that much. Unfortunately it seems people have settled on the single choice which I find offensive, so time for me to whine. :-) plus/minus seem like a *terrible* choice of name to me. First, it completely defeats the point of choosing non symbolic names: Using plus/minus vs +/- is totally arbitrary and inconsistent. Further, using + (or, equivalently, plus) for non commutative operators is a horrible convention. Using it for operators which it doesn't even make sense to commute is even worse. It only makes even the slightest bit of sense in languages which don't support decent function naming and force you to pass everything symbolic through overloading the standard arithmetic operators. Scala isn't one of those languages (thankfully), so lets not inherit their mistakes. |
|
|
Re: Re: [scala-internals] Naming collection operationsplus one
2009/5/12 David MacIver <david.maciver@...> 2009/5/11 martin odersky <martin.odersky@...>: |
|
|
Re: Re: [scala-internals] Naming collection operationsattach/detach ?
On Tue, May 12, 2009 at 12:04 PM, Ricky Clarkson <ricky.clarkson@...> wrote: plus one -- Viktor Klang Senior Systems Analyst |
|
|
RE: [scala-internals] Naming collection operations+1 Odd Möller From: John Nilsson
[mailto:john@...] including/excluding ? On Mon, May 11, 2009 at 10:18 AM, martin odersky
<martin.odersky@...> wrote: I have a question concerning an alternative naming for the +
and - |
|
|
Re: Re: [scala-internals] Naming collection operationsminus 1
So should we do away with "string 1" + "string 2" as well then? 'totally arbitrary' it is not
2009/5/12 Ricky Clarkson <ricky.clarkson@...> plus one -- Rob, Lafros.com |
|
|
Re: Re: [scala-internals] Naming collection operations2009/5/12 Rob Dickens <arctic.bob@...>:
> minus 1 > So should we do away with "string 1" + "string 2" as well then? In an ideal world, absolutely 110%. + for String concatenation is terrible on so many levels. It exists in Scala solely because it was believed that Java people were too used to it to do without it. But this battle is already lost, > 'totally arbitrary' it is not "precedent" is just another way of saying "those who are unable to learn from history are doomed to repeat it" |
|
|
Re: Re: [scala-internals] Naming collection operationsI agree with David: + should sum elements of same type.
My opinion: Do not add functional plus single element and minus single element operations for a while (forcing user to write items ++ Seq(elem) ) for a while. Deprecate all def +, def -, def +=, def -= opertaions. Since Scala 2.9: def + to pure functional sum two collections. def - to pure functional subtraction of second collection from first def += like "addAll" in JDK def -= like "removeAll" in JDK Since Scala 2.10: def ++ to add single element to the new collection def -- to remove single element from the collection def ++= to add single element to the collection and return unit ("add in JDK) def --= "remove" in JDK I remember, that Martin would like to have Seq[String]() + "x" to yield string. With these proposals, result of that operation will be Seq[Any] with single char inside (if String has type Seq[Char]). Anyway, it's great that + will have no side-effect some day. S. On Tue, May 12, 2009 at 13:54, David MacIver <david.maciver@...> wrote: > 2009/5/11 martin odersky <martin.odersky@...>: >> It seems plus/minus has the relative majority of votes. Let's use that then. > > It's a bit late for me to get in this discussion now, but I was > avoiding it on the assumption that people would choose something > vaguely sensible and given that the details really didn't matter that > much. Unfortunately it seems people have settled on the single choice > which I find offensive, so time for me to whine. :-) > > plus/minus seem like a *terrible* choice of name to me. First, it > completely defeats the point of choosing non symbolic names: Using > plus/minus vs +/- is totally arbitrary and inconsistent. > > Further, using + (or, equivalently, plus) for non commutative > operators is a horrible convention. Using it for operators which it > doesn't even make sense to commute is even worse. It only makes even > the slightest bit of sense in languages which don't support decent > function naming and force you to pass everything symbolic through > overloading the standard arithmetic operators. Scala isn't one of > those languages (thankfully), so lets not inherit their mistakes. |
|
|
Re: [scala-internals] Naming collection operationsStepan Koltsov wrote:
> I agree with David: + should sum elements of same type. > > I think David was saying that + may work on many types, but it should satisfy the commutativity property regardless of the type. Hence the earlier objection to String.+ which is associative, but not commutative. I also agree that with regard to String.+ "this battle is lost" but nonetheless any future "plus" should satisfy commutativity (history is a learning opportunity). For what it is worth, Haskell's MonadPlus.mplus doesn't necessarily satisfy commutativity (though it must for associativity) and this has always bothered me, just a little. -- Tony Morris http://tmorris.net/ |
|
|
Re: Re: [scala-internals] Naming collection operationsShould the battle turn against plus and minus at the 11th hour, I
thought newWith and newWithout were the best. -- Paul Phillips | If this is raisin, make toast with it. Caged Spirit | Empiricist | i pull his palp! |----------* http://www.improving.org/paulp/ *---------- |
|
|
Re: Re: [scala-internals] Naming collection operationsI'd vote for incl(uding)/excl(uding)
|
|
|
Re: Re: [scala-internals] Naming collection operations+1
I think using + from string concatenation is an abomination (ok...that's a little melodramatic, but...)... ...that being said it is already in so many languages that it would confuse people to not have it. On Tue, May 12, 2009 at 6:59 AM, David MacIver <david.maciver@...> wrote: 2009/5/12 Rob Dickens <arctic.bob@...>: -- http://erikengbrecht.blogspot.com/ |
|
|
Re: Re: [scala-internals] Naming collection operations2009/5/12 Landei <Daniel.Gronau@...>:
> > I'd vote for incl(uding)/excl(uding) For what it's worth, this is my favourite so far too. I don't have a strong opinion other than "not plus/minus" though. |
| < Prev | 1 - 2 - 3 - 4 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |