Home > Community > Forums > Custom IC SKILL > What is the difference between ~> and ->


* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 What is the difference between ~> and -> 

Last post Mon, Mar 11 2013 6:41 AM by Andrew Beckett. 2 replies.
Started by howardhaoracle 08 Mar 2013 10:41 AM. Topic has 2 replies and 793 views
Page 1 of 1 (3 items)
Sort Posts:
  • Fri, Mar 8 2013 10:41 AM

    What is the difference between ~> and -> Reply


    Please explain the difference between using ~> and ->  ?? When do you use ~>  or ->?

    I looked at some Skill codes and I see both are used

     Thanks for your explanation..



    • Post Points: 20
  • Fri, Mar 8 2013 11:17 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,598
    • Points 16,075
    Re: What is the difference between ~> and -> Reply

     Hi Howard,

    The basic answer is that "~>" should be used for database objects (and CDF, techfiles, constraints...) whereas the "->" operator is for "everything else" such as windows, menu structures, form structures, disembodied property lists, tables etc.  Often they can be used interchangeably but with one big difference: the ~> operator can handle a list on its left hand side (input) and expand the query for each of the elements on the left.  Here's a brief example:

    cv = geGetEditCellView()
    => (db:0x16fcba12 db:0x16fcba13 db:0x16fcba14 db:0x16fcba15 ...)
    => ("Out" "net9" "A" "vss!" "B" ...)

    In the example the second ~> (in red) has a list as its input and it queries the "name" attribute for each of the members and returns the list of results.  If you tried "->" for the second query ("name") it will return nil, but if you used it for the "cv~>nets" query it would work since there is only one thing in its input on the left.

    Hopefully this clarifies the main differences.  Generally speaking you should use the "~>" for database objects, techfile access, constraint object access and so on, and use "->" for everything else.



    • Post Points: 20
  • Mon, Mar 11 2013 6:41 AM

    Re: What is the difference between ~> and -> Reply

    What Lawrence says is not strictly correct. Actually you can use the -> and ~> interchangeably except on lists, where they behave differently. With a list, if you use -> then you are treating the list as a disembodied property list where you have a list with a dummy value first (often nil) followed by key/value pairs where the key is a symbol. So for example:



     > dpl
    (nil shape "circle" colour "red")
    > dpl->shape
    > dpl->shape="square"
    > dpl->shape
    > dpl
    (nil shape "square" colour "red")

    If you use ~> on a list, then it effectively does a foreach mapcar over the list, applying the ~> operator on each member of the list and returning a list of the results. This is as Lawrence mentioned above. So doing:


    is like doing:

    foreach(mapcar net cv~>nets net~>name)

    but obviously shorter and more to the point.

    So ~> can be used for windows, menu structures, form structures, tables and so on - just not disembodied property lists.

    Regards (and sorry to be pedantic!),


    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by howardhaoracle at 08 Mar 2013 10:41 AM. Topic has 2 replies.