This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Autocompletion in REPL and implicit conversions

1 reply
Cay Horstmann
Joined: 2009-09-04,
User offline. Last seen 42 years 45 weeks ago.
Of course, you are right when one hits TAB right after the period. In my scenario, I typed "Hello".i and expected 

indexOf indexOfSlice         indexWhere          
indices              init             inits
intersect            isDefinedAt          isEmpty
isInstanceOf         isTraversableAgain iterator 

Just for grins, I tried hitting TAB in my terminal window. I got

Display all 2674 possibilities? (y or n)

Pretty clever, huh?

Of course, when I hit

sca TAB

I get

scala      scalac     scaladoc   scalap     scalaup    scanimage

So, no, I am not holding the REPL to the same standards as an IDE. Just to the same standards as the autocompletion feature in my humble bash shell :-)

Also, with other collections. we DO have the behavior that you abhor. Try

val lst = List(1)
lst. TAB

You get a lot of methods.

WIth all this thoughtful background information, it's no longer such a terrible idea to expand implicits, right? :-)

Thanks,

Cay



On Sun, Oct 16, 2011 at 9:45 AM, Paul Phillips <paulp@improving.org> wrote:
On Sun, Oct 16, 2011 at 8:35 AM, Cay Horstmann <cay.horstmann@gmail.com> wrote:
> Note that "intersect" doesn't show up in the autocompletion. It doesn't make
> autocompletion all that useful if implicit conversions aren't taken into
> account.

I always want to strangle people who say stuff like this (no offense)
because you are basically holding the repl to IDE standards.  Give me
the IDE team instead of the entire compiler to myself and then maybe
we'll see stuff like this.  But that said, you don't want this
feature.  It is very, very noisy to have all the collections methods
show up on anything which might be a collection.  Here's what would be
added to the output you show above, just from the conversion to
StringOps.  Do you really want to visually parse this all the time?
(And that's not all of it: String implicitly converts to a number of
things.)

++                   ++:                  +:                   /:
            /:\
:+                   ::                   :::                  :\
            addString
aggregate            andThen              apply
asInstanceOf         canEqual
collect              collectFirst         combinations
companion            compose
contains             containsSlice        copyToArray
copyToBuffer         corresponds
count                diff                 distinct             drop
            dropRight
dropWhile            endsWith             exists               filter
            filterNot
find                 flatMap              flatten              fold
            foldLeft
foldRight            forall               foreach
genericBuilder       groupBy
grouped              hasDefiniteSize      head
headOption           indexOf
indexOfSlice         indexWhere           indices              init
            inits
intersect            isDefinedAt          isEmpty
isInstanceOf         isTraversableAgain
iterator             last                 lastIndexOf
lastIndexOfSlice     lastIndexWhere
lastOption           length               lengthCompare        lift
            map
mapConserve          max                  maxBy                min
            minBy
mkString             nonEmpty             orElse               padTo
            par
partition            patch                permutations
prefixLength         product
productArity         productElement       productIterator
productPrefix        reduce
reduceLeft           reduceLeftOption     reduceOption
reduceRight          reduceRightOption
repr                 reverse              reverseIterator
reverseMap           reverse_:::
sameElements         scan                 scanLeft
scanRight            segmentLength
seq                  size                 slice                sliding
            sortBy
sortWith             sorted               span                 splitAt
            startsWith
stringPrefix         sum                  tail                 tails
            take
takeRight            takeWhile            toArray
toBuffer             toIndexedSeq
toIterable           toIterator           toList               toMap
            toSeq
toSet                toStream             toString
toTraversable        transpose
union                unzip                unzip3               updated
            view
withFilter           zip                  zipAll               zipWithIndex

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Autocompletion in REPL and implicit conversions

On Sun, Oct 16, 2011 at 10:16 AM, Cay Horstmann wrote:
> Display all 2674 possibilities? (y or n)

Yes, this is terrible. Long ago I implemented grouping and slow
verbosity increases on multiple tabs, but it is stranded amidst my
repl rewrite. Multiple tabs is how I intend to expose methods
available via implicits as well.

> Also, with other collections. we DO have the behavior that you abhor.

Yes, and I dislike it so much that it enters into my decision as to
whether to use composition or inheritance with collections. (Which is
to say, I avoid inheriting from them even more than I would anyway.)

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland