Pointers in Skill?

Discussion in 'Cadence' started by Rajeswaran M, Mar 17, 2006.

  1. Rajeswaran M

    Rajeswaran M Guest

    Is it possible to pass pointers to skill code similar to C?

    When the number of variables and skill functions increases, it becomes
    very difficult to use them as private variables.
     
    Rajeswaran M, Mar 17, 2006
    #1
  2. Rajeswaran M

    Jimka Guest

    No, there is no need for pointers in skill as such. all values are
    passed
    as pointers actually. There are many ways of reducing the number of
    variables you are passing.

    If the variables are related to each other you can create various
    types of data structures and pass them. e.g., hash tables or
    defstruct or defclass.

    If you simply want to access certain variables in various functions
    without having to pass them, you can use the lexical environment and
    declare the functions in a lexical scope and simply use them.
    You can also declare local functions who can see all the variables
    in the lexical parent functions.
     
    Jimka, Mar 17, 2006
    #2
  3. Rajeswaran M

    fogh Guest

    Jim,
    Local functions would be in SKILL++ , not SKILL, right ?
     
    fogh, Mar 17, 2006
    #3
  4. Rajeswaran M

    Jimka Guest

    hmmm,
    in the dynamically scoped environment you'd have to use funcall or
    apply
    to call a local function whereas in the lexical environment you would
    not.

    SKILL does not really provde nice syntax for local functions but as
    with most syntax issues you can hide it with a macro to hide the lambda
    syntax ....

    ;; the following works in SKILL++
    (defun foo (x y z)
    (let ((bar (lambda (a b ) a + b )))
    ;; now bar is a local function
    x + (bar y z)))


    ;; outside of SKILL++ you'd need to use funcall
    (defun foo (x y z)
    (let ((bar (lambda (a b ) a + b )))
    ;; now bar is a local function
    x + (funcall 'bar y z)))


    I have a macro Vflet that allows functions to be which allows you to
    define function locally similar to the syntax of let.


    (defun foo (x y z)
    (Vflet ((bar (a b) ;; define a local function bar with parameters
    a b
    a + b )))
    ;; now bar is a local function
    x + (bar y z)))

    One very nice thing about local functions (expecially in the lexical
    environment,
    is that hty also have access to the variables declared outside of them.
    For example the function, bar, has access to x, y and z, but you don't
    have to pass x, y, and z explicitly to it.
     
    Jimka, Mar 17, 2006
    #4
  5. Rajeswaran M

    Rajeswaran M Guest

    Jim,

    Thanks. I need to explore much on the lexical environment.

    Regards
    Rajeswaran

    I need to store some pointer location where
     
    Rajeswaran M, Mar 20, 2006
    #5
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.