<p>When I type check, I generate IR and serialize them to avoid retypechecking of libraries, which is usually unchanged after the first compilation. However, I store these variable references using objects in Java, and here's a problem. When I serialize these libraries individually:</p>
<ul>
<li>A, B, C where B, C depends on A</li>
</ul>
<p>The objects for symbols in A are serialized into different things in the serialized version of B and C, causing the result to be incorrect, because the symbols in A are unique, while serialization makes different copies of them.</p>
<p>How is this problem solved in general? Do I create URL kind of thing?</p>

<compilers><intermediate-representation><serialization>
How to serialize IR with cross references?
CC BY-SA 4.0
2024-02-19T18:30:29.440Z
Java's solution is to use "binary names", which are unique stable across compilation, and aren't quite the same thing as "canonical names" (which, sadly, aren't unique and some things don't have them).
kaya3
CC BY-SA 4.0
2024-02-20T03:47:14.700Z
@kaya3 care to elaborate and make it an answer?
ice1000
CC BY-SA 4.0
2024-02-20T18:22:07.587Z
I don't know what kind of elaboration would be useful to you because I'm not sure what part of "use unique, stable IDs" needs elaboration - that is, the question is like "my IDs aren't stable and this is a problem, what should I do?", so "make them stable" seems like a straightforward and complete answer. There must be some difficulty beyond that otherwise you wouldn't ask the question, but you'll have to explain what the difficulty is.
kaya3
CC BY-SA 4.0
2024-02-21T01:09:57.967Z
I think in general it's just unclear how to make a stable id unless you get rid of any possible overloading and just make full qualified names as ids.
ice1000
CC BY-SA 4.0
2024-02-22T18:15:10.737Z
You can allow overloading of functions and methods, it just means the stable name of an overloaded method includes the parameter type list. Here's how Java does it in `.class` files, for example: https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.3.3
kaya3
# How to serialize IR with cross references?
Posted by: username_0 on 2024-02-19
When I type check, I generate IR and serialize them to avoid retypechecking of libraries, which is usually unchanged after the first compilation. However, I store these variable references using objects in Java, and here's a problem. When I serialize these libraries individually:

* A, B, C where B, C depends on A

The objects for symbols in A are serialized into different things in the serialized version of B and C, causing the result to be incorrect, because the symbols in A are unique, while serialization makes different copies of them.

How is this problem solved in general? Do I create URL kind of thing?
**Tags:** compilers intermediate-representation serialization
> **Comments:**
> **username_1**: Java's solution is to use "binary names", which are unique stable across compilation, and aren't quite the same thing as "canonical names" (which, sadly, aren't unique and some things don't have them).  
> **username_0**: @kaya3 care to elaborate and make it an answer?  
> **username_1**: I don't know what kind of elaboration would be useful to you because I'm not sure what part of "use unique, stable IDs" needs elaboration - that is, the question is like "my IDs aren't stable and this is a problem, what should I do?", so "make them stable" seems like a straightforward and complete answer. There must be some difficulty beyond that otherwise you wouldn't ask the question, but you'll have to explain what the difficulty is.  
> **username_0**: I think in general it's just unclear how to make a stable id unless you get rid of any possible overloading and just make full qualified names as ids.  
> **username_1**: You can allow overloading of functions and methods, it just means the stable name of an overloaded method includes the parameter type list. Here's how Java does it in `.class` files, for example: https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.3.3  
---
## 0 answers
