1structure C = struct 2val _ = TextIO.print "linking values"; 3 4fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting value A."^id^" found "^s); 5 6val _ = check A.a "a"; 7val _ = check A.b "b"; 8val _ = check A.c "c"; 9val _ = check A.d "d"; 10 11val _ = check A.e "e"; 12val _ = check A.f "f"; 13val _ = check A.g "g"; 14val _ = check A.h "h"; 15 16val _ = check A.i "i"; 17val _ = check A.j "j"; 18val _ = check A.k "k"; 19val _ = check A.l "l"; 20 21(* unqualified *) 22 23val _ = TextIO.print "\nopen A"; 24 25open A; 26 27fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting value "^id^" found "^s); 28 29val _ = check a "a"; 30val _ = check b "b"; 31val _ = check c "c"; 32val _ = check d "d"; 33 34val _ = check e "e"; 35val _ = check f "f"; 36val _ = check g "g"; 37val _ = check h "h"; 38 39val _ = check i "i"; 40val _ = check j "j"; 41val _ = check k "k"; 42val _ = check l "l"; 43 44(* local unqualified *) 45 46val _ = TextIO.print "\nlocal open A"; 47 48local open A in 49fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting value "^id^" found "^s); 50 51val _ = check a "a"; 52val _ = check b "b"; 53val _ = check c "c"; 54val _ = check d "d"; 55 56val _ = check e "e"; 57val _ = check f "f"; 58val _ = check g "g"; 59val _ = check h "h"; 60 61val _ = check i "i"; 62val _ = check j "j"; 63val _ = check k "k"; 64val _ = check l "l"; 65end 66 67(* structures *) 68 69val _ = TextIO.print "linking structures"; 70 71fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting structure A."^id^" found "^s); 72 73val _ = check A.a.v "a"; 74val _ = check A.b.v "b"; 75val _ = check A.c.v "c"; 76val _ = check A.d.v "d"; 77 78val _ = check A.e.v "e"; 79val _ = check A.f.v "f"; 80val _ = check A.g.v "g"; 81val _ = check A.h.v "h"; 82 83val _ = check A.i.v "i"; 84val _ = check A.j.v "j"; 85val _ = check A.k.v "k"; 86val _ = check A.l.v "l"; 87 88(* unqualified *) 89val _ = TextIO.print "\nopen A"; 90 91fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting structure "^id^" found "^s); 92 93open A; 94 95val _ = check a.v "a"; 96val _ = check b.v "b"; 97val _ = check c.v "c"; 98val _ = check d.v "d"; 99 100val _ = check e.v "e"; 101val _ = check f.v "f"; 102val _ = check g.v "g"; 103val _ = check h.v "h"; 104 105val _ = check i.v "i"; 106val _ = check j.v "j"; 107val _ = check k.v "k"; 108val _ = check l.v "l"; 109 110(* local unqualified *) 111val _ = TextIO.print "\nlocal open A"; 112 113fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting structure "^id^" found "^s); 114 115local open A in 116val _ = check a.v "a"; 117val _ = check b.v "b"; 118val _ = check c.v "c"; 119val _ = check d.v "d"; 120 121val _ = check e.v "e"; 122val _ = check f.v "f"; 123val _ = check g.v "g"; 124val _ = check h.v "h"; 125 126val _ = check i.v "i"; 127val _ = check j.v "j"; 128val _ = check k.v "k"; 129val _ = check l.v "l"; 130end 131 132(* functors *) 133 134val _ = TextIO.print "linking functors"; 135 136fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting sfunctor A."^id^" found "^s); 137 138val _ = check let structure V = A.a() in V.v end "a"; 139val _ = check let structure V = A.b() in V.v end "b"; 140val _ = check let structure V = A.c() in V.v end "c"; 141val _ = check let structure V = A.d() in V.v end "d"; 142 143val _ = check let structure V = A.e() in V.v end "e"; 144val _ = check let structure V = A.f() in V.v end "f"; 145val _ = check let structure V = A.g() in V.v end "g"; 146val _ = check let structure V = A.h() in V.v end "h"; 147 148val _ = check let structure V = A.i() in V.v end "i"; 149val _ = check let structure V = A.j() in V.v end "j"; 150val _ = check let structure V = A.k() in V.v end "k"; 151val _ = check let structure V = A.l() in V.v end "l"; 152 153(* unqualified *) 154val _ = TextIO.print "\nopen A"; 155 156fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting structure "^id^" found "^s); 157 158open A; 159 160val _ = check let structure V = a() in V.v end "a"; 161val _ = check let structure V = b() in V.v end "b"; 162val _ = check let structure V = c() in V.v end "c"; 163val _ = check let structure V = d() in V.v end "d"; 164 165val _ = check let structure V = e() in V.v end "e"; 166val _ = check let structure V = f() in V.v end "f"; 167val _ = check let structure V = g() in V.v end "g"; 168val _ = check let structure V = h() in V.v end "h"; 169 170val _ = check let structure V = i() in V.v end "i"; 171val _ = check let structure V = j() in V.v end "j"; 172val _ = check let structure V = k() in V.v end "k"; 173val _ = check let structure V = l() in V.v end "l"; 174 175(* local unqualified *) 176val _ = TextIO.print "\nlocal open A in"; 177 178fun check id s = TextIO.print (if id = s then "\nOK: "^s else "\nFAIL expecting structure "^id^" found "^s); 179 180local open A in 181 182val _ = check let structure V = a() in V.v end "a"; 183val _ = check let structure V = b() in V.v end "b"; 184val _ = check let structure V = c() in V.v end "c"; 185val _ = check let structure V = d() in V.v end "d"; 186 187val _ = check let structure V = e() in V.v end "e"; 188val _ = check let structure V = f() in V.v end "f"; 189val _ = check let structure V = g() in V.v end "g"; 190val _ = check let structure V = h() in V.v end "h"; 191 192val _ = check let structure V = i() in V.v end "i"; 193val _ = check let structure V = j() in V.v end "j"; 194val _ = check let structure V = k() in V.v end "k"; 195val _ = check let structure V = l() in V.v end "l"; 196end 197 198 199(* shadowing of units by structures *) 200 201structure X = 202 struct 203 val a = "X.a" 204 structure a = struct val v = "X.a" end 205 functor a ()= struct val v = "X.a" end 206 val x = "X.x" 207 structure x = struct val v = "X.x" end 208 functor x ()= struct val v = "X.x" end 209 end 210 211fun check d id s = 212 TextIO.print ("\n"^d^(if id = s then " OK: "^s else "FAIL expecting "^id^" found "^s)); 213 214(* open A B X *) 215val _ = TextIO.print "\n open A B X"; 216open A B X 217val _ = check "value" a "X.a"; 218val _ = check "value" b "B.b"; 219val _ = check "value" x "X.x"; 220val _ = check "value" y "B.y"; 221val _ = check "structure" a.v "X.a"; 222val _ = check "structure" b.v "B.b"; 223val _ = check "structure" x.v "X.x"; 224val _ = check "structure" y.v "B.y"; 225val _ = check "functor" (let structure V = a() in V.v end) "X.a"; 226val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 227val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 228val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 229 230val _ = TextIO.print "\nlocal open A B X"; 231local open A B X in 232val _ = check "value" a "X.a"; 233val _ = check "value" b "B.b"; 234val _ = check "value" x "X.x"; 235val _ = check "value" y "B.y"; 236val _ = check "structure" a.v "X.a"; 237val _ = check "structure" b.v "B.b"; 238val _ = check "structure" x.v "X.x"; 239val _ = check "structure" y.v "B.y"; 240val _ = check "functor" (let structure V = a() in V.v end) "X.a"; 241val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 242val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 243val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 244end 245 246(* open B A X *) 247 248val _ = TextIO.print "\nopen B A X"; 249open B A X 250val _ = check "value" a "X.a"; 251val _ = check "value" b "b"; 252val _ = check "value" x "X.x"; 253val _ = check "value" y "B.y"; 254val _ = check "structure" a.v "X.a"; 255val _ = check "structure" b.v "b"; 256val _ = check "structure" x.v "X.x"; 257val _ = check "structure" y.v "B.y"; 258val _ = check "functor" (let structure V = a() in V.v end) "X.a"; 259val _ = check "functor" (let structure V = b() in V.v end) "b"; 260val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 261val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 262 263val _ = TextIO.print "\nlocal open B A X"; 264local open B A X in 265val _ = check "value" a "X.a"; 266val _ = check "value" b "b"; 267val _ = check "value" x "X.x"; 268val _ = check "value" y "B.y"; 269val _ = check "structure" a.v "X.a"; 270val _ = check "structure" b.v "b"; 271val _ = check "structure" x.v "X.x"; 272val _ = check "structure" y.v "B.y"; 273val _ = check "functor" (let structure V = a() in V.v end) "X.a"; 274val _ = check "functor" (let structure V = b() in V.v end) "b"; 275val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 276val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 277end 278 279(* open B X A *) 280 281val _ = TextIO.print "\nopen B X A" ; 282open B X A 283val _ = check "value" a "a"; 284val _ = check "value" b "b"; 285val _ = check "value" x "X.x"; 286val _ = check "value" y "B.y"; 287val _ = check "structure" a.v "a"; 288val _ = check "structure" b.v "b"; 289val _ = check "structure" x.v "X.x"; 290val _ = check "structure" y.v "B.y"; 291val _ = check "functor" (let structure V = a() in V.v end) "a"; 292val _ = check "functor" (let structure V = b() in V.v end) "b"; 293val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 294val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 295 296val _ = TextIO.print "\nlocal open B X A"; 297local open B X A in 298val _ = check "value" a "a"; 299val _ = check "value" b "b"; 300val _ = check "value" x "X.x"; 301val _ = check "value" y "B.y"; 302val _ = check "structure" a.v "a"; 303val _ = check "structure" b.v "b"; 304val _ = check "structure" x.v "X.x"; 305val _ = check "structure" y.v "B.y"; 306val _ = check "functor" (let structure V = a() in V.v end) "a"; 307val _ = check "functor" (let structure V = b() in V.v end) "b"; 308val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 309val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 310end 311 312(* open A X B *) 313 314val _ = TextIO.print "\nopen A X B" ; 315open A X B 316val _ = check "value" a "B.a"; 317val _ = check "value" b "B.b"; 318val _ = check "value" x "X.x"; 319val _ = check "value" y "B.y"; 320val _ = check "structure" a.v "B.a"; 321val _ = check "structure" b.v "B.b"; 322val _ = check "structure" x.v "X.x"; 323val _ = check "structure" y.v "B.y"; 324val _ = check "functor" (let structure V = a() in V.v end) "B.a"; 325val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 326val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 327val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 328 329val _ = TextIO.print "\nlocal open A X B"; 330local open A X B in 331val _ = check "value" a "B.a"; 332val _ = check "value" b "B.b"; 333val _ = check "value" x "X.x"; 334val _ = check "value" y "B.y"; 335val _ = check "structure" a.v "B.a"; 336val _ = check "structure" b.v "B.b"; 337val _ = check "structure" x.v "X.x"; 338val _ = check "structure" y.v "B.y"; 339val _ = check "functor" (let structure V = a() in V.v end) "B.a"; 340val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 341val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 342val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 343end 344 345(* open X A B *) 346val _ = TextIO.print "\nopen X A B" ; 347open X A B 348val _ = check "value" a "B.a"; 349val _ = check "value" b "B.b"; 350val _ = check "value" x "X.x"; 351val _ = check "value" y "B.y"; 352val _ = check "structure" a.v "B.a"; 353val _ = check "structure" b.v "B.b"; 354val _ = check "structure" x.v "X.x"; 355val _ = check "structure" y.v "B.y"; 356val _ = check "functor" (let structure V = a() in V.v end) "B.a"; 357val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 358val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 359val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 360 361val _ = TextIO.print "\nlocal open X A B"; 362local open X A B in 363val _ = check "value" a "B.a"; 364val _ = check "value" b "B.b"; 365val _ = check "value" x "X.x"; 366val _ = check "value" y "B.y"; 367val _ = check "structure" a.v "B.a"; 368val _ = check "structure" b.v "B.b"; 369val _ = check "structure" x.v "X.x"; 370val _ = check "structure" y.v "B.y"; 371val _ = check "functor" (let structure V = a() in V.v end) "B.a"; 372val _ = check "functor" (let structure V = b() in V.v end) "B.b"; 373val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 374val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 375end 376 377(* open X B A *) 378val _ = TextIO.print "\nopen X B A" ; 379open X B A 380val _ = check "value" a "a"; 381val _ = check "value" b "b"; 382val _ = check "value" x "X.x"; 383val _ = check "value" y "B.y"; 384val _ = check "structure" a.v "a"; 385val _ = check "structure" b.v "b"; 386val _ = check "structure" x.v "X.x"; 387val _ = check "structure" y.v "B.y"; 388val _ = check "functor" (let structure V = a() in V.v end) "a"; 389val _ = check "functor" (let structure V = b() in V.v end) "b"; 390val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 391val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 392 393val _ = TextIO.print "\nlocal open X B A"; 394local open X B A in 395val _ = check "value" a "a"; 396val _ = check "value" b "b"; 397val _ = check "value" x "X.x"; 398val _ = check "value" y "B.y"; 399val _ = check "structure" a.v "a"; 400val _ = check "structure" b.v "b"; 401val _ = check "structure" x.v "X.x"; 402val _ = check "structure" y.v "B.y"; 403val _ = check "functor" (let structure V = a() in V.v end) "a"; 404val _ = check "functor" (let structure V = b() in V.v end) "b"; 405val _ = check "functor" (let structure V = x() in V.v end) "X.x"; 406val _ = check "functor" (let structure V = y() in V.v end) "B.y"; 407end 408 409val _ = TextIO.print "\n"; 410 411end;