• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. member vs. memq

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 13837
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

member vs. memq

Aldo2
Aldo2 over 5 years ago

Hello,

Lint suggests to replace member with memq, but the two commands are not fully interchangeable:

  1. member("qqq" parseString("qqq www")) works.
  2. memq("qqq" parseString("qqq www"))   does not work.

How should I modify the 2nd expression to make memq work properly?

Thank you

Best regards,

Aldo

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago

    Aldo,

    The best (and only correct) way to modify the second code is to use member instead. You should not use eq/memq with strings (the documentation says that you should only use it with symbols and lists). In general, eq compares the pointer to the object, so would only be successful if the object is exactly the same object. The problem is that if you use eq type checks on strings, it ought to work if you do:

    a="aaa"
    b=a
    c="aaa"

    eq(a b) => t

    However, the outcome of eq(a c) is a little more uncertain - because there is some optimisation on string storage so that it (sometimes) will smartly avoid double creation of identical strings in memory - however, you are then at the mercy of when that optimisation does or doesn't work. I used to have an example article which showed a very strange case where using memq to compare cell names was dependent upon the presence of a variable assignment later in the code - however, we retired that article a few years after we improved the documentation to make it much more strongly say that you should only use eq/memq on symbols and lists.

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago in reply to Andrew Beckett

    BTW, you could use memq if you used concat to convert both strings to be symbols, but I wouldn't advise that as a good approach. For a start, it's unlikely to be any more efficient than using member, and secondly it would pollute the symbol table with arbitrary symbols (and symbols don't get garbage collected).

    So don't do this:

    mapcar('symbolToString memq(concat("qqq") mapcar('concat parseString("qqq" "www"))))

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information