[SAL-HELP] Can anyone give me an example of the syntax for array literals?

Bruno Dutertre bruno at csl.sri.com
Thu Oct 26 10:58:40 PDT 2006


mwwhalen at rockwellcollins.com wrote:
> Hello all,
> 
>   Sorry to show my ignorance here; I have the SAL language guide, so I
> should be able to do this on my own.  However, I can't, for the life of me,
> figure out how to define the values of cells in an array constant:
> 
>       A: ARRAY [0..4] OF BOOLEAN  = [TRUE, FALSE, TRUE, TRUE, FALSE];
> 
> Any help is appreciated!
> 
> :-) Mike
> 

Hi Mike,

There is no construct like this in SAL because array indices can be of
other types than integer ranges, but there are equivalent (less concise/uglier?)
ways of defining array constants.

The simplest form is to use an array expression of the form

   [[i: index_type] expr]

For the example above, you can write

   [[i: [0..4]] (i=0 OR i=2 OR i=3) ]

or more explicitly

   [[i: [0..4]] IF i=0 THEN true
                ELSIF i=1 THEN false
                 ...
                ENDIF]



Bruno

> --------------------------------------
> Dr. Michael Whalen
> Rockwell Collins Inc.
> 400 Collins Rd. NE
> Cedar Rapids, IA 52498
> 
> Office Phone: 612-625-4543
> Cell Phone: 651-442-8834
> 


-- 
Bruno Dutertre                             | bruno at csl.sri.com
CSL, SRI International                     | fax: 650 859-2844
333 Ravenswood Avenue, Menlo Park CA 94025 | tel: 650 859-2717



More information about the SAL-HELP mailing list