

下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、Programming LanguagesDan GrossmanMutable ReferencesML has (separate) mutationMutable data structures are okay in some situationsWhen “update to state of world” is appropriate modelBut want most language constructs truly immutableML does this with a separate construct: referencesIntroducing now becau
2、se will use them for next closure idiomDo not use references on your homeworkYou need practice with mutation-free programmingThey will lead to less elegant solutions2Dan Grossman, Programming LanguagesReferencesNew types: t ref where t is a typeNew expressions:ref e to create a reference with initia
3、l contents ee1 := e2 to update contents !e to retrieve contents (not negation)3Dan Grossman, Programming LanguagesReferences example4Dan Grossman, Programming Languagesval x = ref 42 val y = ref 42 val z = xval _ = x := 43val w = (!y) + (!z) (* 85 *)(* x + 1 does not type-check *)A variable bound to a reference (e.g., x) is still immutable: it will always refer to the same referenceBut the contents of the reference may change via :=And there may be aliases to the reference, which matter a lotReferences are first-class valuesLike a one
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- DB32/T 3587-2019慈姑-泥鰍共作生產(chǎn)技術(shù)規(guī)程
- DB32/T 3565-2019公路工程環(huán)境監(jiān)理規(guī)程
- DB32/T 2342-2019港口建設(shè)項(xiàng)目檔案管理規(guī)范
- DB31/T 960-2015冷卻塔循環(huán)水系統(tǒng)節(jié)能監(jiān)測方法
- DB31/T 478.1-2014主要工業(yè)產(chǎn)品用水定額及其計(jì)算方法第1部分:火力發(fā)電
- DB31/T 329.13-2021重點(diǎn)單位重要部位安全技術(shù)防范系統(tǒng)要求第13部分:槍支彈藥生產(chǎn)、經(jīng)銷、存放、射擊場所
- DB31/T 1281-2021爆炸性氣體環(huán)境倉儲智能系統(tǒng)安全技術(shù)規(guī)范
- DB31/T 1249-2020醫(yī)療廢物衛(wèi)生管理規(guī)范
- DB31/T 1146.7-2022智能電網(wǎng)儲能系統(tǒng)性能測試技術(shù)規(guī)范第7部分:微電網(wǎng)孤網(wǎng)運(yùn)行應(yīng)用
- DB31/T 1037-2017林業(yè)有害生物測報(bào)點(diǎn)設(shè)置技術(shù)規(guī)范
- YOLO目標(biāo)檢測算法的改進(jìn)與優(yōu)化
- GB/T 43449-2023法庭科學(xué)毒物分析實(shí)驗(yàn)室質(zhì)量控制規(guī)范
- [甘肅]最新甘肅省造價文件匯編(310頁)
- 工業(yè)企業(yè)環(huán)境管理工作要點(diǎn)
- 臨床技術(shù)操作規(guī)范麻醉學(xué)分冊
- 高中物理實(shí)驗(yàn)考點(diǎn)整合電學(xué)PPT課件
- 《愛蓮說》學(xué)案
- PA66增強(qiáng)增韌研究
- 全國大學(xué)生數(shù)學(xué)建模競賽優(yōu)秀論文選之易拉罐形狀和尺寸的最優(yōu)設(shè)計(jì)
- API-682密封系統(tǒng)-中英文對照版
- 新生兒沐浴及撫觸ppt課件
評論
0/150
提交評論