Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  Index 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020 
<== Date ==> <== Thread ==>

Subject: RE: V4 Data Types: Request for tagged unions
From: "Jeff Hill" <johill@lanl.gov>
To: "'Ralph Lange'" <Ralph.Lange@bessy.de>, "'EPICS Core Talk'" <core-talk@aps.anl.gov>
Date: Wed, 15 Jun 2005 17:46:42 -0600
I think that unions are really best summarized as a way to save space by
storing different things in the same place at different times. Of course
there are chances for mistakes because the type varies at runtime instead of
being checked by the compiler. So, looking at this example I would probably
advocate storing the date for different states independently unless there is
a significant storage space optimization that might be obtained.

GDD provides an implementation of tagged unions should we decide that we
need one.

Jeff

-----Original Message-----
From: Ralph Lange [mailto:Ralph.Lange@bessy.de] 
Sent: Wednesday, June 15, 2005 8:20 AM
To: EPICS Core Talk
Subject: V4 Data Types: Request for tagged unions

As a result of intensive (almost excessive) discussions of today, I 
would like to spit out a requirement for:

  Tagged unions as a basic V4 data type

Let me give one example based on the idea of implementing Sequencer 
state sets as (pseudo) record instances:
The sequences will (hopefully) be able to support parametrized states, 
i.e. instead of changing global variables and plainly switching to 
another state, you can switch to the new state handing in some 
parameters. If the current state of a state set is to be represented by 
a (pseudo) field of the state set's (pseudo) record, that field's data 
has the form of a tagged union, i.e. it is organized like:

state = init     state = start     state = wait
   int i1           double d;         char t1;
   int i2           int j1;           int j3;
                    int j2;

Such a field can transparently contain the complete state information, 
including any parameters for that state.

Structures (such as the parameter list) are represented by C structures 
internally and property catalogs externally (through DA).
The state tag is represented as an enum (both internally and externally).

The DA representation of the tagged union would be a property catalog 
that consists of the tag (which is an enum) and the properties that can 
vary in type, name and number depending on the tag's value.

Access can be managed by generating DA code that:
 - find()s only properties that are present - depending on the tag value
 - traverse()s always the tag first, then the matching properties, both 
for the reading and writing traversals

The only place where DA has to be extended is for the new method (under 
construction) that traverses the property names and natural types. For 
that special traversal, the tagged union is very much like an enum, but 
with an additional property catalog connected to each of the enum 
choices that can be traversed to find out the properties and types 
present in that state of the union. ((Delivers a State of the Union 
Address?))

In other words ... A regular plain enum (functionality that is already 
implemented) is just a special case of a tagged union: an empty union 
with no data properties connected to the state string.

What do you think!?
Ralph

-- 
Ralph Lange               Ralph.Lange@bessy.de     Tel: +49 30 6392-2117
BESSY Controls Group      www.bessy.de             Fax:      ...   -4859



Replies:
Re: V4 Data Types: Request for tagged unions Benjamin Franksen
References:
V4 Data Types: Request for tagged unions Ralph Lange

Navigate by Date:
Prev: RE: Fundamental Types document Jeff Hill
Next: RE: V4 Database Access Jeff Hill
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020 
Navigate by Thread:
Prev: Re: V4 Data Types: Request for tagged unions Andrew Johnson
Next: Re: V4 Data Types: Request for tagged unions Benjamin Franksen
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·