Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Variant records seem like a dead feature now. When should I use them instead of tagged types?

0
Posted

Variant records seem like a dead feature now. When should I use them instead of tagged types?

0

This is an instance of a much more general question: “When should I use what kind of type?” The simple answer is: “When it makes sense to do so.” The real key to chosing a type in Ada is to look at the application, and pick the type that most closely models the problem. For instance, if you are modelling data transmission where the message packets may contain variable forms of data, a variant record –not a hierarchy of tagged types– is an appropriate model, since there may be no relationship between the data items other than their being transmitted over one channel. If you choose to model the base type of the messages with a tagged type, that may present more problems than it solves when communicating across distinct architectures. [More to be said about variant programming vs. incremental programming.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.