• 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. how to use setf_last

Stats

  • Replies 8
  • Subscribers 147
  • Views 397
  • Members are here 0

how to use setf_last

kkdesbois
kkdesbois 6 days ago

Hello, 

I can not understand the error message returned in the following example : 

A='("a" "b" "c" "d")
(setf_last A "e")

*** Error in routine cddr:
Message: *Error* cddr: argument #1 should be a list (type template = "l") at line 48 of file "*ciwInPort*" - "e"
Entering new debug toplevel due to error:

Is it possible to replace "d" by "e" without using the following syntax : 
(setf (car (last A)) "e")

Laurent.

  • Cancel
  • Sign in to reply
Parents
  • Andrew Beckett
    Andrew Beckett 6 days ago

    Hi Laurent,

    The whole point of the setf_* helper functions/macros is to allow the simple use of setf(place value) and then this is transformed into the right function with maybe more cryptic syntax. For example:

    expandMacroDeep('(setf (car (last A)) "e"))
    car(rplaca(last(A) "e"))

    You could (I guess) use setf_last directly, but you need to remember that last() is a list - so you'd need to use (setf_last (list "e") A) - note the arguments are also the opposite way around than you were using.

    I would strongly suggest you use setf rather than directly calling the helper function.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett 6 days ago

    Hi Laurent,

    The whole point of the setf_* helper functions/macros is to allow the simple use of setf(place value) and then this is transformed into the right function with maybe more cryptic syntax. For example:

    expandMacroDeep('(setf (car (last A)) "e"))
    car(rplaca(last(A) "e"))

    You could (I guess) use setf_last directly, but you need to remember that last() is a list - so you'd need to use (setf_last (list "e") A) - note the arguments are also the opposite way around than you were using.

    I would strongly suggest you use setf rather than directly calling the helper function.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • kkdesbois
    kkdesbois 6 days ago in reply to Andrew Beckett

    Thanks for the prompt reply.
    I missed the point in the doc about the reversed arguments for the helper functions!
    I'll follow your suggestion

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 6 days ago in reply to kkdesbois

    Not sure it's going to help you memorize it but if you were to build a self helper, you will realize that in a self_helper the value to set can only be the first argument.

    If you have a fancy getter function : 

    (defun fancy_getter ( positional_arg @optional optional_arg @rest args ) "Return whatever value" ... )

    To build a self_helper for it, you need to take all the getter arguments but also the value to set which is a necessary argument.

    The only way to make it necessary is to start with it. It will look like this : 

    (defun setf_fancy_getter ( value positional_arg @optional optional_arg @rest args ) "Set whatever value and return it" ... )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 6 days ago in reply to Aurel B

    BTW you can also use defsetf to associate the update function (the helper) with the access function. Doesn't particularly make it easier to understand though ;-)

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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