-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Dave Berry wrote:
The reason your example fails is that sharing is only allowed between non-ground types.
Yes, I was wondering about this restriction - is there some reason for it?
More generally, I'm slightly confused about the distinction between "where" and "sharing"; it seems that sharing is a restricted form of the signature constraint that can be imposed by using "where". Is this the case, or is there a deeper difference? (as you pointed out, the structure sharing is just an abbreviation for individual type sharing... would be nice to have something similar for "where" - where signature A = B... )
You are attempting to share a non-ground type (BVertex.Boundary.data) with a ground type (RGVertex.Boundary.data = unit). In this instance you would need a "where" clause instead. I agree that the PolyML error message isn't clear.
If you replace BVertex with Vertex, there is no constraint on RGVertex.Boundary.data because Vertex doesn't include a Boundary substructure.
Oh yeah, for some reason I missed that! thanks - that certainly clears up my confusion.
thanks! lucas
At 16:35 23/05/2008, Lucas Dixon wrote: I've been trying to use the module system and come across a few issues, some of which I cannot easily pin down, and one which I can.
The issue I can clearly identify concerns what seems to be failure of associativity in structure sharing, and is demonstrated in the following:
signature ORD_DATA = sig type data end; signature VERTEX = sig type name type data end;
signature BVERTEX = sig structure Boundary : ORD_DATA include VERTEX end;
signature GRAPH = sig structure Vertex : VERTEX type T; end;
signature BGRAPH = sig include GRAPH; structure BVertex : BVERTEX sharing Vertex = BVertex end;
signature RG_VERTEX = sig include BVERTEX where type Boundary.data = unit end;
signature RG_GRAPH = sig include BGRAPH structure RGVertex : RG_VERTEX sharing BVertex = RGVertex (* why is it OK if I change BVertex to Vertex? *) end
Running this gives the error: Error: in '/tmp/sml25644bEn', line 26. Cannot share: (unit) is a type function Found near sig include BGRAPH structure RGVertex : RG_VERTEX sharing BVertex = RGVertex end
Exception- Fail Static errors (pass2) raised
Apart from just being confused by what the error means, I am confused that given, in BGraph, "sharing Vertex = BVertex", later I get an error if "BVertex = RGVertex" but not if "Vertex = RGVertex".
Is there some subtle (or obvious?) thing I'm missing?
Another thing I don't quite understand, but which I suspect is just part of the definition of ML, is that you cannot write "sharing type localtype = globaltype", is there some clever reason why this isn't allowed? Or even "sharing local_structure = global_structure", would sometimes be nice. :)
The other issue I have is with the names given to types being printed in error messages; is there any way to control this? I sometimes seem to get mis-typed types; which makes errors hard to spot. A common thing I find is that a parameterised type loses it's parameter. I have example of this I can repeat, but they require a large amount of code... I'll try to find a smaller example.
any suggestions/corrections/infomration, and possibly bug fixes, very welcome! :)
cheers, lucas