Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Computer Aided Design - CAD > Cadence > Re: what is the...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 3990 of 4373
Post > Topic >>

Re: what is the difference between defun and procedure?

by Andrew Beckett <andrewb@[EMAIL PROTECTED] > May 9, 2008 at 10:47 AM

Riad KACED wrote, on 05/09/08 00:51:
> Hi Ahmad,
> 
> That's a very hard question and this is my attempt
> 
> 1. To start, there is a bit of comment from the SKILL Language User
> Guide.
> In SKILL, function calls can be written in either of the following
> notations:
>  - Algebraic notation used by most programming languages: func( arg1
> arg2 …)
>  - Prefix notation used by the Lisp programming language: (func arg1
> arg2 …)
> 
> For comparison, here is a SKILL program written first in algebraic
> notation, then the same
> program, also implemented in SKILL, using a Lisp style of programming.
> 
> procedure( fibonacci(n)
>    if( (n == 1 || n == 2) then
>      1
>       else fibonacci(n-1) + fibonacci(n-2)
>    )
> )
> 
> Here is the same program implemented in SKILL using a Lisp style of
> programming.
> (defun fibonacci (n)
>    (cond
>       ((or (equal n 1) (equal n 2)) 1)
>       (t (plus (fibonacci (difference n 1))
>          (fibonacci (difference n 2)))
>       )
>    )
> )
> 
> 2. My point of view is both defun and procedure are doing the same job
> with a slightly different syntax. The only difference is :
> With defun, you have to keep a white space between the function name
> and the "(" of arguments, i.e fibonacci (n).
> 3. defun is a lisp function actually whereas procedure is a pure skill
> function
> 4. I'm enable to tell you whether there is any difference in terms of
> performance. I don't think so otherwise Cadence would have advised one
> syntax preferably to the other.
> 5. My thinking is that defun suits the Lisp-ish chaps and procedure
> the C-ish ones. So the choice is yours !
> 
> Let's wait for other comments ...
> 
> Riad.

It boils down to being a slightly different syntax. They both produce
function 
objects. The key difference is that the first argument to procedure is a
list 
containing both the function name and the formal arguments. Whereas with
defun, 
the first argument is the function name, and the second argument is the
formal
argument list.

As Riad said, defun is primarily there because
(defun funName (arg1 arg2) body...) is the LISP way of doing things.

Andrew.
 




 3 Posts in Topic:
what is the difference between defun and procedure?
Reotaro Hashemoto <ahm  2008-05-08 08:34:42 
Re: what is the difference between defun and procedure?
Riad KACED <riad.kaced  2008-05-08 16:51:00 
Re: what is the difference between defun and procedure?
Andrew Beckett <andrew  2008-05-09 10:47:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 21:21:30 CST 2008.