Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is structure sharing broken in Standard ML?

Tags:

sml

In a 2013 presentation about the future of Standard ML, Bob Harper says, on slide 9, that "structure sharing is broken". Can someone give more detail on that? I don't have enough experience with sharing to understand what he meant.

like image 245
Ionuț G. Stan Avatar asked Mar 06 '15 13:03

Ionuț G. Stan


2 Answers

It is broken because as specified, it cannot be applied to structures that have transparent type components. For example:

signature S = sig type t; type u = int end
signature T =
sig
  structure A : S
  structure B : S
  sharing A = B
end

would already be illegal, although you would naturally expect this to be fine.

The history here is that structure sharing was introduced in SML'90, where no transparent type components existed. With SML'97, those were added. At that point, the whole business with sharing constraints became somewhat obsolete because they were (to some extent) superseded by "where type" constraints. So, the semantics of sharing was vastly simplified, and structure sharing degraded from a primitive to syntactic sugar. But this sugar was defined such that it only worked with SML'90 programs -- which makes sense if you only view it as a backwards compatibility hack, but not if you consider structure sharing a central feature of SML'97.

People in the SML community disagree about the relevance of sharing constraints. Some consider them obsolete, some still important. Unfortunately, SML'97 failed to add a "where structure" constraint, which could have properly replaced structure shairing.

like image 97
Andreas Rossberg Avatar answered Sep 24 '22 15:09

Andreas Rossberg


Andreas Rossberg's answer has already clarified matters, but I've written to professor Harper before Andreas' answer. I'm posting his reply here for the curious:

It's a purely technical problem with the definition. In SML 90 there was a notion of structure sharing above and beyond the constituent type sharing. In SML 97 structure sharing was redefined to mean sharing of the constituent types, but the formulation is incorrect (there are several candidate replacements, so compilers differ in their behavior). It's a dark corner anyway, so in the scheme of things it is very minor, but the mistake and the associated incompatibilities render it useless any more.

like image 45
Ionuț G. Stan Avatar answered Sep 22 '22 15:09

Ionuț G. Stan