From: Tim M. <tm...@un...> - 2013-04-14 23:49:44
|
Hi everyone, You wrote: > This lead me to thinking - do signatures really need to be duplicated > everywhere? I imagine that the signature of schema A would be the same > everywhere? Can we reuse the signature, or is it important to duplicate > and assign new IDs to the name? > It was, at some point, very important to create new signatures, because referenced schema names declare new variables into the name space of a specification, and we can't have 2 variables with the same IDs if they refer to different declarations. The IDs were a CZT-specific thing (i.e. not part of the standard), and were used by other tools (the typechecker does not require them because it keeps track of references in the type environments itself). Now, I'm not sure whether they are still important in CZT. Other tools may still rely on them. I'm pretty sure the rules package used them at some point. Andrius, have you tried running all CZT tests to see what happens when you don't create new signatures? If some of the rules tests fail, then the dependency there means that we can't just switch these off in the typechecker. If not, then there is a chance these aren't used any more. If I do a grep -r for "getId" and "setId" in the rules package, there are a number of references, but most look to be just ensuring that they are passed around. If it was decided that IDs are no longer necessary (I know at one point there was talk of dropping them), then they should be removed from the ZName class all together, along with any reference to them in all of the other packages. Anything else would be too confusing. If they don't play an important role, then the memory saving may be worth removing them, but I'd wager the change would be tedious. > The massive space saving becomes quite obvious when you think about it. > If we have schema references, every RefExpr would duplicate the whole > schema definition when typechecked, hence creating a lot of new ZName > instances and consuming all this memory. > It wouldn't duplicate the whole schema definition -- it would only create a new Signature instance, and new ZName instances for all names inside the signature. The existing type instances are used. This alone will certainly account for a large chunk of memory in a state-machine, because every schema inclusion (including Xi/Delta) will create a new ZName for every name in that inclusion (two for Delta inclusions). Cheers, Tim |