Pointers in Skill?

R

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.
 
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 wrote:

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.
Jim,
Local functions would be in SKILL++ , not SKILL, right ?
 
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.
 
Jim,

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

Regards
Rajeswaran

I need to store some pointer location where


fogh wrote:
Jimka wrote:

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.


Jim,
Local functions would be in SKILL++ , not SKILL, right ?
 

Welcome to EDABoard.com

Sponsor

Back
Top