• 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. [Skill++ ]Private functions/methods inside a Class

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 2283
  • 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

[Skill++ ]Private functions/methods inside a Class

GiuseppeGreco
GiuseppeGreco over 5 years ago

Hello,

I tried to figure out how to create a private method/function for a class.

I wrote this code:

defclass( A
()
((slot @initform 1 @initarg a)
)
procedure(print_priv()
print("Hello!")
)
)

myA = makeInstance('A)

The questions are:

1) Is there a way to retrieve print_priv() function from the class instance myA?

2) If this piece of code does not make sense, is there a way to define a private methods inside a class definition so to have them full packaged?

Thank you

Giuseppe

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago

    Hi Giuseppe,

    Functions are not (and cannot) be defined within the defclass definition. Currently everything beyond the slot definition (the third argument to defclass) is ignored - it's there to support potential future options which might get added . You certainly cannot put any function definitions there - they will simply be ignored.

    This doesn't make any sense within the object model - functions (methods) are not defined as part of the class in the language. They are defined outside of classes.

    It is not currently possible to lexically define methods such that they are only visible within a lexical scope and hence are private. There's one existing enhancement request, CCR 1434162, filed by one of my team which is asking for this, but nothing has been implemented yet. You can define normal functions lexically so they are hidden, but not defmethod.

    So private methods are only really possible with the object system by naming convention - maybe prefixing with underscore is a good cue that they should not be used outside the code? That convention is used elsewhere for private/public functions.

    Andrew.

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

    Thank you Andrew for the clarification,

    Best regards,

    Giuseppe

    • 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