proj_ref.km 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. type Vector {
  2. x: Integer,
  3. y: Integer
  4. };
  5. type Matrix {
  6. start: Vector,
  7. size: Vector
  8. };
  9. function String: &(Vector) => String
  10. & {x,y} => { "(?,?)" (x.{String}, y.{String}) };
  11. function String: &(Matrix) => String
  12. & {start,size} => { "[?,?]" (start.{String}, size.{String}) };
  13. do
  14. // TODO: test for the whole return value of ref call (pair[0], pair[1])
  15. let p := { |Vector| { x: 1, y: 2 } },
  16. let q1 := p.(x).{->},
  17. let q2 := (p.(x) <- 3),
  18. let q3 := (p.(y) <- -9),
  19. let u := { |Matrix| { start: p, size: q2 } },
  20. let v1 := u.(start).(x).{->},
  21. let v2 := (u.(start).(y) <- 4),
  22. let v3 := (u.(size).(x) <- 5),
  23. let str := [
  24. p.{String},
  25. q1.{String},
  26. q2.{String},
  27. q3.{String},
  28. v1.{String},
  29. v2.{String},
  30. v3.{String}
  31. ].{join \n},
  32. { os::println str }
  33. . { crash-on-error };