www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Are compile time generated, stable and unique IDs possible?

reply =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
Let's assume I have an GUI application and I want to record some 
user-actions which can be replayed.

And this replay should be possible even if the application layout 
changes. Hence, I somehow need to identify the run-time objects in a 
way that this identification stays the same while the app is further 
developed and between user sessions.

And I don't want to manually manage all IDs (initially) but use the 
compiler for this.

Is there any way to generate such stable unique IDs at compile-time? I 
can imagine that his maybe needs to be combined with a mixin that is 
used inside a constructor to get IDs into run-time objects.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
May 08 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 5/8/20 8:45 AM, Robert M. Münch wrote:
 Let's assume I have an GUI application and I want to record some 
 user-actions which can be replayed.
 
 And this replay should be possible even if the application layout 
 changes. Hence, I somehow need to identify the run-time objects in a way 
 that this identification stays the same while the app is further 
 developed and between user sessions.
 
 And I don't want to manually manage all IDs (initially) but use the 
 compiler for this.
 
 Is there any way to generate such stable unique IDs at compile-time? I 
 can imagine that his maybe needs to be combined with a mixin that is 
 used inside a constructor to get IDs into run-time objects.
 
The compiler needs something to go off of that isn't going to change between revisions. Maybe the fully qualified name? Then you can hash that. -Steve
May 08 2020