欢迎来到天天文库
浏览记录
ID:6025288
大小:231.50 KB
页数:37页
时间:2017-12-25
《《汽车综合故障诊断与修复》课程建 ..》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、InitializingMutuallyReferentialObjectsChallengesandAlternativesDonSymeMicrosoftResearch,CambridgeUKRestrictionsinCoreMLOnlyrecursivefunctions:"letrec"canonlybindlambdaexpressionsalsorecursivedatainOCamlNopolymorphicrecursion"letrec"bindingsmustberecursivelyusedatu
2、niformpolymorphicinstantiationsValuerestrictionlimitsonthegeneralizationofpolymorphicbindingsthatinvolvecomputationThistalkisabout...TheproblemofinitializingmutuallyreferentialcomputationalstructuresEspeciallyinthepresenceofabstraction+effectsAnalternativewaytoadd
3、ressthisproblemButonethatfitsnicelywithCoreMLRelatedtheoryandpracticeaka“ValueRecursion”Pleasenote!RecursivedefinitionsinMLletrecfx=ifx>0thenx*f(x)else1CoreMLletrecones=1::onesOCamlRecursivefunctionRecursivedataletconsxy=x::yletrecones=cons1onesImmediatedependency
4、typewidgetletrecwidget=MkWidget(fun...->widget)PossiblydelayeddependencyExample1:TypicalGUItoolkitsform=Form(menu)menu=Menu(menuItemA,menuItemB)menuItemA=MenuItem(“A”,{menuItemB.Activate})menuItemB=MenuItem(“B”,{menuItemA.Activate})Aspecification:menumenuItemB
5、menuItemAformtypeForm,Menu,MenuItemvalMkForm:unit->FormvalMkMenu:unit->MenuvalMkMenuItem:string*(unit->unit)->MenuItemvalactivate:MenuItem->unit…Assume:AssumethisabstractAPIEvolvingbehaviourWidgetsExample1:TheObviousIsNotAllowedletrecform=MkForm()andmenu=MkMenu()a
6、ndmenuItemA=MkMenuItem(“A”,(fun()->activatemenuItemB)andmenuItemB=MkMenuItem(“B”,(fun()->activatemenuItemA)…Theobviouscodeisn'tallowed:Constructioncomputationsonr.h.sofletrecDelayedself-referencesletform=MkForm()letmenu=MkMenu()letmenuItemB=refNoneletmenuItemA=M
7、kMenuItem(“A”,(fun()->activate(the(!menuItemB))menuItemB:=Some(MkMenuItem(“B”,(fun()->activatemenuItemA))…Example1:ExplicitInitializationHolesinMLSoweendupwriting:MLprogrammersunderstandref,Some,None.Theuseofexplicitmutationisdeeplydisturbing.VRMitigationTechniq
8、ue1Manuallybuild“initialization-holes”andfillinlaterMostprogrammershatethis.WhybotherusingMLifyouendupdoingthis?Example1:ImperativeWiringinML//Createle
此文档下载收益归作者所有