The case function in SKILL

Discussion in 'Cadence' started by Suresh Jeevanandam, Jul 16, 2004.

  1. Andrew and all,
    I expect the following code to print "Case 2". But it does not do so.
    Why?. Please help/


    obj = 1
    case( type(obj)
    ( 'list
    println("Case 1")
    )
    ( ('fixnum 'flonum 'string )
    println("Case 2")
    )
    )

    thanks,
    Suresh
     
    Suresh Jeevanandam, Jul 16, 2004
    #1
  2. Suresh,

    Remove all the quotes (') from your example below. They shouldn't
    be there, because the match values in the branches of the case
    are literals; they are not evaluated, and hence the 'list is seen
    as (quote list) and ('fixnum 'flonum 'string) is seen as
    ((quote fixnum) (quote flonum) (quote string))
    which is why they don't match.

    Andrew.
     
    Andrew Beckett, Jul 16, 2004
    #2
  3. Suresh Jeevanandam

    Jay Lessert Guest

    Good question, wish I knew the answer. ('fixnum 'flonum 'string)
    *is* a list of symbols and lists of strings work, and lists
    of reals work, etc. But a list of symbols doesn't seem
    to work. Hrmph.

    -Jay-
     
    Jay Lessert, Jul 16, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.