













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














val
val
fun f(
fun f(
fun f(
− Identifier on left refers to a memory location, called an L-value − Identifier on right refers to contents, called an R-value
− Most languages ◊ A variable names a storage location ◊ Contents of location can be read, can be changed − ML reference cell ◊ A mutable cell is another type of value ◊ Explicit operations to read contents or change contents ◊ Separates naming (declaration of identifiers) from “variables”
− Identifier on left refers to a memory location, called an L-value − Identifier on right refers to contents, called an R-value
− Most languages ◊ A variable names a storage location ◊ Contents of location can be read, can be changed − ML reference cell ◊ A mutable cell is another type of value ◊ Explicit operations to read contents or change contents ◊ Separates naming (declaration of identifiers) from “variables”
− x : int; (* non-assignable integer value ) − y : int ref; ( location whose contents must be integer ) − !y : int; ( the contents of location y ) − ref x : int ref ( constructs new cell initialized to x *)
− operator := is applied to memory cell and new contents
− y := x+3; (* place value of x+3 in cell y; requires x:int and y:int ref ) − y := !y + 3; ( add 3 to contents of y, store in location y; requires y:int ref*)
− x : int; (* non-assignable integer value ) − y : int ref; ( location whose contents must be integer ) − !y : int; ( the contents of location y ) − ref x : int ref ( constructs new cell initialized to x *)
− operator := is applied to memory cell and new contents
− y := x+3; (* place value of x+3 in cell y; requires x:int and y:int ref ) − y := !y + 3; ( add 3 to contents of y, store in location y; requires y:int ref*)
− x : int; (* non-assignable integer value ) − y : int ref; ( location whose contents must be integer ) − !y : int; ( the contents of location y ) − ref x : int ref ( constructs new cell initialized to x *)
− operator := is applied to memory cell and new contents
− y := x+3; (* place value of x+3 in cell y; requires x:int and y:int ref ) − y := !y + 3; ( add 3 to contents of y, store in location y; requires y:int ref*)