R ls( ) 函数的 Scala REPL 等价物

Scala REPL equivalent for R ls( ) function

Scala REPL中是否有任何命令可以打印出已经定义的对象?例如,在 R 控制台中,函数 ls() 打印当前环境中所有已定义的对象。

对于 Scala,R 中没有像 ls() 这样的简单函数。但是可以通过以下方式做类似的事情:

val ls = $intp
ls.allDefinedNames.foreach(println)

ls.+tab 将提供以下选项:

scala> ls.
SparkComputedImports        addImports                  addUrlsToClassPath          allDefinedNames             allImportedNames            asInstanceOf                
beQuietDuring               beSilentDuring              bind                        classOfTerm                 classServerUri              classSymbols                
clearExecutionWrapper       close                       compileSources              compileString               definedSymbolList           definedSymbols              
definedTerms                definedTypes                definitionForName           directBind                  executionWrapper            fallback                    
generatedName               getClassOutputDirectory     global                      implicitSymbols             implicitSymbolsBySource     importedSymbols             
importedSymbolsBySource     importedTermNamed           importedTermSymbols         importedTerms               importedTypeSymbols         importedTypes               
initializeSynchronous       interpret                   interpretSynthetic          isInstanceOf                isNoImports                 isNoPredef                  
isReportingErrors           languageSymbols             languageWildcardHandlers    languageWildcardSyms        languageWildcards           lastWarnings                
methodSymbols               mostRecentVar               namedDefinedTerms           out                         parse                       pathToName                  
rebind                      requestForIdent             requestForName              requestForReqId             requestHistoryForName       reset                       
runtimeClassAndTypeOfTerm   runtimeTypeOfTerm           sessionImportedSymbols      sessionWildcards            setExecutionWrapper         symbolOfLine                
symbolOfTerm                toString                    treesForRequestId           typeOfExpression            typeOfTerm                  valueOfTerm                 
visibleTermNames            wildcardTypes