Quantcast
Channel: Cadence Custom IC Skill Forum
Viewing all articles
Browse latest Browse all 5186

Behavior of case() for boolean values

$
0
0

Hello,

I guess this question was already asked several times, but I could not find a fitting post.

To handle booleans with case(), the values must be specified differently than for normal constants due to the special meaning of 't' and 'nil'. The documentation gives an example, where these cases are given as single-element lists. However, this does not work for me. Here an example (the case code is directly from the manual)

foreach(mapcar myBool '(nil t (nil) (t) 1)
  case( myBool
    (nil 'never) ; this will never match, it is a list of no keys
    (( nil ) nil) ; matches nil
    (( t ) t) ; matches t
    (t (error "Expected t or nil"))
  )
);foreach

=> (never t t t t)

However, when I modify the code this way, it works

foreach(mapcar myBool '(nil t (nil) (t) 1)
  case( myBool
    ('nil nil) ; matches nil
    ('t t) ; matches t
    (t "other")
  )
);foreach

=> (nil t "other" "other" "other")

Is there maybe something wrong with my setup or environment settings?

Best regards
Paul


Viewing all articles
Browse latest Browse all 5186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>