About SKILL ~> and -> Operators

Discussion in 'Cadence' started by Reotaro Hashemoto, Feb 14, 2007.

  1. Hello,
    What are the exact function of the -> and ~> operators?
    Are they quite equivalent?
    Shouldn't I get some help about them if i wrote in the CIW: " ~>??
    " (w/o quotes) ? I tried to do that but it gave me error:
    SYNTAX ERROR found at line 3 column 4 of file *ciwInPort*
    *Error* lineread/read: syntax error encountered in input

    Is there anyone experience about that who might help me?
    Thanks in advance,
    Kind Regards,
     
    Reotaro Hashemoto, Feb 14, 2007
    #1
  2. Reotaro Hashemoto

    sc Guest

    I just found an extract from documentation:
    Arrow (->) Operator The arrow (->) operator can be applied to
    disembodied property lists, defstructs, association tables, and user
    types (special application-supplied types) to access property values.
    The property must always be a symbol and the value of the property can
    be any valid Cadence®

    SKILL language type. Squiggle Arrow (~>) Operator The squiggle arrow
    (~>) operator is a generalization of the arrow operator. It works the
    same way as an arrow operator when applied directly to an object, but
    it can also accept a list of such objects. It walks the list applying
    the arrow operator whenever it finds an atomic object.

    But frankly speaking I have just known about ~> so I can't see any
    difference yet. I mean difference in practical use.
    I hope I've helped you a little bit.
     
    sc, Feb 14, 2007
    #2
  3. Yes, many thanks,
    You'd helped me a lot indeed.. but what about the "~>??" ..
    Morover, i want to know where can i get a document, that's better
    organized than the SKILL user-guide, including a reference of SKILL
    functions, and be good organized as a reference non a manual.

    Thanks and Regards,
    Ahmad,
     
    Reotaro Hashemoto, Feb 14, 2007
    #3
  4. ~? will list all the available properties. Its a list of symbols when
    applied to a db object.
    ~?? is same as above but will return list of pairs of propName and
    propValue.

    When applied on list, it is applied recursively, as ~>propName would do.

    -
    Suresh
     
    Suresh Jeevanandam, Feb 14, 2007
    #4
  5. Some examples:
    Select two or more objects in the design window and do each one and see
    what is getting printed.

    car(geGetSelSet())~>?

    car(geGetSelSet())~>??

    geGetSelSet()~>?

    geGetSelSet()~>??

    To see the difference between ~> and ->, do the following:

    geGetSelSet()~>objType

    geGetSelSet()->objType ; Must return a nil

    -
    Suresh
     
    Suresh Jeevanandam, Feb 14, 2007
    #5
  6. Reotaro Hashemoto

    S. Badel Guest

    Hello,
    as far as I remember, they are equivalent (both evaluate to getq) except that the ~> operator, when
    applied on a list, recurses over the list elements.

    As an example, let's use a list of db objects :
    (db:238579444 db:238574680 db:238575080 db:238579768 db:238585240
    db:238583948 db:238589336 db:238582980 db:238589228 db:238582600
    db:238583340 db:238582144 db:238583264 db:238583056
    )

    Let's try on a single db object :
    "label"

    Both return the same value. Now, let's apply it to the list :
    ("label" "label" "label" "label" "inst"
    "inst" "ellipse" "line" "line" "ellipse"
    "line" "line" "line" "line"
    )
    nil

    So, ~> returns the property for each element of the list, while -> tries to get the property from
    the list itself and returns nil.



    Stéphane
     
    S. Badel, Feb 14, 2007
    #6
  7. Well, if you want a reference guide, look in the SKILL Reference Manual,
    rather than the user guide. The user guide is intended as a book about the
    language, introducing concepts in a similar manner to books on programming.
    Reference manuals are rather dry, and list each function by function - but are
    very useful for reference.

    There are also many other SKILL manuals, covering particular APIs (Application
    Programming Interfaces) - you can find these by using "cdsdoc".

    Also, for a quick reference, you can use the "cdsFinder" UNIX command to bring
    up a simple GUI which allows you search for function names - and gives the
    function template plus a short description (this is no substitute for the full
    documentation, but does help as a useful reminder).

    As for the original question, that's been well answered, but let me quickly add
    my take on this. Essentially they are equivalent, except when it comes to lists.
    If the left hand side is a list, then -> treats it as a disembodied property
    list, whereas ~> does an implicit foreach mapcar on the list. So, if the left
    hand side is a DPL (disembodied property list), you have to use ->, whereas if
    it is a single object you can use either.

    To describe the implicit foreach mapcar behaviour of ~>, here's an
    example:

    objList~>prop

    is equivalent to:

    foreach(mapcar obj objList obj~>prop)

    just a little more concise.

    Regards,

    Andrew.
     
    Andrew Beckett, Feb 16, 2007
    #7
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.