Re: SDL-News: Unions


Subject: Re: SDL-News: Unions
From: Dagbjørn Nogva (dagbjorn#telox.no)
Date: Fri Apr 16 1999 - 07:57:33 GMT


The originator of this message is responsible for its content.
-----From =?iso-8859-1?Q?Dagbj=F8rn?= Nogva <dagbjorn#telox.no> to sdlnews -----

Hello Jo,

> I realise unions are not supported by SDL but can't they be specified as an
> Abstract Data Type and if so does anyone know where this has been done that
> I can cut and paste from as I'm not sure I'd like to go through the
> rigmarole of defining operations and axioms etc....
>

If you are the privileged user of Telelogic's tool set SDT, you can
directly benefit from an extension to the SDL data types called choice.
choice is based on the corresponding ASN.1 data type, however you do
not have to worry about ASN.1. According to SDT documentation,
choice in SDL can be seen as a C union with an implicit tag field.

Example (partly from SDT doc):

  newtype C1 choice
    a Integer;
    b Charstring;
    c Boolean;
  endnewtype;

  dcl var C1;

  task var!b := 'hello'; /* Assign component b */

  decision var!Present: /* Check which component in use */
    (a): 'task handling a type values, ie Integer';
    (b): 'task handling b type values, ie Charstring';
    (c): 'task handling c type values, ie Boolean';
  enddecision;

Nice and neat, isn't it? However, not portable...

Best regards
Dagbjørn Nogva <dagbjorn#telox.no>
Telox AS

-----End text from =?iso-8859-1?Q?Dagbj=F8rn?= Nogva <dagbjorn#telox.no> to sdlnews -----
For help, email "majordomo#sdl-forum.org" with the body of your email as:
    help
or (iff this does not answer your question) email: owner-sdlnews#sdl-forum.org



This archive was generated by hypermail 2a23 : Sun Jun 16 2013 - 10:41:40 GMT