Hello Paul,
I'm not a compiler developer, but if you are not afraid of writing a
short spad program, then you can get around it, see attachment.
)compile rec.spad
(2) -> x := makeRec(2,3)
(2) [a = 3, b = 2]
Type: MyRec
(3) -> recA(x)
(3) 3
Type: PositiveInteger
(4) -> a := 0
(4) 0
Type: NonNegativeInteger
(5) -> recA(x)
(5) 3
Type: PositiveInteger
If you don't want to do this, you must wait for some smarter person that
tells you how to define getA in order to refer to the right a.
I've found another workaround.
(1) -> Z ==> Integer
Type: Void
(2) -> R ==> Record(a: Z, b: Z)
Type: Void
(3) -> makeR(x:Integer, y:Integer):R == [x,y]
Function declaration makeR : (Integer, Integer) -> Record(a: Integer
,b: Integer) has been added to workspace.
Type: Void
(4) -> aForGetA := 'a
(4) a
Type: Variable(a)
(5) -> getA(r:R):Integer == r.aForGetA
Function declaration getA : Record(a: Integer,b: Integer) -> Integer
has been added to workspace.
Type: Void
(6) -> r := makeR(3, 5)
Compiling function makeR with type (Integer, Integer) -> Record(a:
Integer,b: Integer)
(6) [a = 3, b = 5]
Type: Record(a: Integer,b: Integer)
(7) -> getA(r)
Compiling function getA with type Record(a: Integer,b: Integer) ->
Integer
(7) 3
Type: PositiveInteger
(8) -> a := 0
(8) 0
Type: NonNegativeInteger
(9) -> getA r
(9) 3
Ralf