get pointer to data in SKILL?

E

Erik Wanta

Guest
See the ;*** comments below. It seems to me the lines are equivalent.

The following works.
gndList->myGnd=cons(inst~>name gndList->myGnd)

Is it that get returns the data and not a pointer to the data? If so,
is there a function similar to get that will return the pointer?

printf("nep()\n")

procedure(nep()
prog(()

cv=geGetWindowCellView()

gndList=list(nil)


foreach(inst cv~>instances



when(gndName=dbGetPropByName(inst "vss")~>value

when(!member(concat(gndName) gndList)

putprop(gndList list(nil) concat(gndName))
) ; when


when(gndName

;***
;This works!
putprop(gndList cons(inst~>name get(gndList
concat(gndName))) concat(gndName))


;***
;This fails!
;get(gndList concat(gndName))=cons(inst~>name get(gndList
concat(gndName)))


) ; when


) ; when

) ; foreach


return(t)

) ; prog
) ; procedure
 
Hi Erik,

No, SKILL doesn't work that way. You can't return a pointer to a value (some
lisp variants allow this using things like (setf) ) and then assign to it.

The -> operator corresponds to either the function (getq) if you are using it to
retrieve a value, or (putpropq) if you are assigning a value.

Remember, all operators in SKILL are really implemented as functions underneath;
if you are using:

a->b=3

it ends up as (putpropq a 3 b)

whereas

a->b

ends up as (getq a b)

The "q" in these functions means that the property name argument is implicitly
quoted - i.e. there is no need to put a ' in front of the name.

All (get) and (putprop) are, are lambda versions of these functions which
interpret all their arguments before they are called. Consequently you can then
pass an expression or function (or variable) as the name of the property to
access.

If you want to implement pointers, the way to do that is to pass lists, and
then use destructive operators (such as the -> disembodied property
operators, or things like (rplaca)). For example (in C-like syntax for the hard
of lisp):

procedure(myUpdateVal(thing val)
rplaca(thing val)
)

a=list(3)
b=list(5)

myUpdateVal(a 20)
a => (20)
myUpdateVal(b 19)
b => (19)

The other approach is to use things like macros (using defmacro ), but that's
not really pointers still...

To be honest, you don't really need them in SKILL, because there are other ways
of doing things which avoid the need for them in the first place.
Remember that when you pass lists, structures, arrays, association tables etc
to functions, it actually passes a reference (i.e. a pointer) to that object,
and hence you can modify the contents directly. Variables you can sort of
pass a pointer to by passing the name of the variable (but it's best to do this
with macros, rather than relying on run-time evaluation). What you can't do is
pass a pointer to a variable or list element or whatever so that they can all
be updated the same way, if you see what I mean.

Regards,

Andrew.

On 13 Feb 2004 09:28:47 -0800, erikwanta@starband.net (Erik Wanta) wrote:

See the ;*** comments below. It seems to me the lines are equivalent.

The following works.
gndList->myGnd=cons(inst~>name gndList->myGnd)

Is it that get returns the data and not a pointer to the data? If so,
is there a function similar to get that will return the pointer?

printf("nep()\n")

procedure(nep()
prog(()

cv=geGetWindowCellView()

gndList=list(nil)


foreach(inst cv~>instances



when(gndName=dbGetPropByName(inst "vss")~>value

when(!member(concat(gndName) gndList)

putprop(gndList list(nil) concat(gndName))
) ; when


when(gndName

;***
;This works!
putprop(gndList cons(inst~>name get(gndList
concat(gndName))) concat(gndName))


;***
;This fails!
;get(gndList concat(gndName))=cons(inst~>name get(gndList
concat(gndName)))


) ; when


) ; when

) ; foreach


return(t)

) ; prog
) ; procedure
--
Andrew Beckett
Senior Technical Leader
Custom IC Solutions
Cadence Design Systems Ltd
 

Welcome to EDABoard.com

Sponsor

Back
Top