I'm writing a real time strategy game and I'm using numeric ids on everything.
For example, each unit has an Id, and the command to attack another unit contains the target unit id. I keep all units in a (Dict UnitId Unit), so I can access each quickly. It's not as handy (or fast) as having pointers, but it is more robust: say the target unit is destroyed, the attacking unit will be left with Nothing to attack rather than a seg fault/reference error. On Friday, September 23, 2016 at 8:24:38 AM UTC+10, Dénes Harmath wrote: > > Hi everybody, > > in a typical model, there are cross-references: e.g. we have artists and > albums, and the album refers to its artist. How do we model this in Elm? A > possible approach is giving unique identifiers to objects and store the > referred object's identifiers similar to the TodoMVC example - is this > mechanism extracted to some library in a type-safe way? > > Thank you in advance, > thSoft > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
