文档介绍:TheScalaProgrammingLanguagepresentedbyDonnaMalayeriWhyanewlanguage?ponentsoftwareTwohypotheses:ponentsoftwareshouldbescalableThesameconceptsdescribesmallandlargepartsRatherthanaddinglotsofprimitives,position,FeaturesofScalaScalaisbothfunctionalandobject-orientedeveryvalueisanobjecteveryfunctionisavalue--includingmethodsScalaisstaticallytypedincludesalocaltypeinferencesystem::Pairp=newPair<Integer,String>(1,"Scala"); inScala:valp=newMyPair(1,"scala");MorefeaturesSupportslightweightsyntaxforanonymousfunctions,higher-orderfunctions,nestedfunctions,curryingML-stylepatternmatchingIntegrationwithXMLcanwriteXMLdirectlyinScalaprogramcanconvertXMLDTDintoScalaclassdefinitionsSupportforregularexpressionpatternsOtherfeaturesAllowsdefiningnewcontrolstructureswithoutusingmacros,andwhilemaintainingstatictypingAnyfunctioncanbeusedasaninfixorpostfixoperatorCandefinemethodsnamed+,<=or::,theactualdefparametersarenotevaluatedandano-argumentfunctionispassedWhileloopexampleobjectTargetTest1withApplication{defloopWhile(defcond:Boolean)(defbody:Unit):Unit=if(cond){body;loopWhile(cond)(body);}vari=10;loopWhile(i>0){(i);i=i-1}}DefineloopWhilemethodUseitwithnicesyntaxScalaclasshierarchyScalaobjectsystemClass-poundtypes,andviewsallowformoreflexibilityClassesandObjectstraitNat;objectZeroextendsNat{defisZero:boolean=true;defpred:Nat= thrownewError("");}(n:Nat)extendsNat{defisZero:boolean=false;defpred:Nat=n;}