Format for dtr

Discussion in 'AutoCAD' started by Adesu, Jul 15, 2004.

  1. Adesu

    Adesu Guest

    Dear Lispers.
    I want ask you alls,how the best place of "dtr",before defun (format 1) or
    in defun (format 2),if it see in program procedure,thanks for your reply
    Best regards
    Ade Suharna

    format 1

    (defun dtr (a)
    (* pi (/ a 180.0)))
    (defun c:xx (/)
    bla...bla...
    )

    format 2

    (defun c:xx (/)
    (defun dtr (a)
    (* pi (/ a 180.0)))
    bla...bla...
    )
     
    Adesu, Jul 15, 2004
    #1
    1. Advertising

  2. Adesu

    Paul Turvill Guest

    It's a matter of preference, I guess. Either will make the (dtr ...)
    function available to other LISP routines, but format 2 will unnecessarily
    redefine the function every time you run command XX. If you're a stickler
    for "efficient" code, use format 1.
    ___

    "Adesu" <> wrote in message
    news:40f5db98_2@newsprd01...
    > Dear Lispers.
    > I want ask you alls,how the best place of "dtr",before defun (format 1) or
    > in defun (format 2),if it see in program procedure,thanks for your reply
     
    Paul Turvill, Jul 15, 2004
    #2
    1. Advertising

  3. Adesu

    ECCAD Guest

    Ade,
    My 2 cents:
    I would say it depends. IF you are sending a program to someone (and it needs dtr..) then include it in the program. That way, you won't get beat-up for forgetting it..
    IF you are doing a larger process, using many programs, then, include it in some loaded utility.

    Bob
     
    ECCAD, Jul 15, 2004
    #3
  4. One key point that both Paul and Bob missed was that your sample for format
    2, as shown, will _definitely_ lead to bugs in the long run. Why? Because
    you did not declare the subroutine's symbol as local.

    So imagine this scenario for format 2, with two different .lsp files:

    (defun C:XX (/ x)
    (defun dtr (a)
    (* pi (/ a 180.0)))
    (setq x (dtr 30.0))
    ;| rest of code |;
    )

    (defun C:YY ()
    (defun dtr (a)
    (alert (strcat "My message is " a)))
    (dtr "I'm going to cause a bug.")
    ;| rest of code |;
    )

    The code loaded last will win, breaking the _other_ program.

    So, if you are going to embed subrs, either use names you know/guess will be
    unique, or declare them as local symbols.

    However, with (dtr), the subr will be used in many programs, so the best
    approach is to have that subr in a separate .lsp file altogether, and
    autoload the subr in the main functions. That way you need to maintain the
    actual (dtr) code in one place only.

    --
    R. Robert Bell


    "Adesu" <> wrote in message
    news:40f5db98_2@newsprd01...
    Dear Lispers.
    I want ask you alls,how the best place of "dtr",before defun (format 1) or
    in defun (format 2),if it see in program procedure,thanks for your reply
    Best regards
    Ade Suharna

    format 1

    (defun dtr (a)
    (* pi (/ a 180.0)))
    (defun c:xx (/)
    bla...bla...
    )

    format 2

    (defun c:xx (/)
    (defun dtr (a)
    (* pi (/ a 180.0)))
    bla...bla...
    )
     
    R. Robert Bell, Jul 15, 2004
    #4
  5. Adesu

    ECCAD Guest

    <snip>IF you are doing a larger process, using many programs, then, include it in some loaded utility.<snip>
    I don't think the intention was to 'redefine' the rtd function,
    merely get it available.
    Your sample is 're-writing' the function, and in doing so, yes, the 'last' loaded will survive..perhaps yielding unexpected results.

    Bob
     
    ECCAD, Jul 15, 2004
    #5
  6. X-zarchary! ;^)

    --
    R. Robert Bell


    "ECCAD" <> wrote in message
    news:13055928.1089907828472.JavaMail.jive@jiveforum1...
    <snip>IF you are doing a larger process, using many programs, then, include
    it in some loaded utility.<snip>
    I don't think the intention was to 'redefine' the rtd function,
    merely get it available.
    Your sample is 're-writing' the function, and in doing so, yes, the 'last'
    loaded will survive..perhaps yielding unexpected results.

    Bob
     
    R. Robert Bell, Jul 15, 2004
    #6
  7. Adesu

    ECCAD Guest

    <Grin>
     
    ECCAD, Jul 15, 2004
    #7
  8. Adesu

    DEVItG Guest

    What do you mean????

    a degree to radian defun???





    "ECCAD" <> escribió en el mensaje
    news:...
    > <Grin>
     
    DEVItG, Jul 19, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ghiggins457

    error: no function definition: DTR

    ghiggins457, Mar 2, 2004, in forum: AutoCAD
    Replies:
    2
    Views:
    634
    Allen Johnson
    Mar 2, 2004
  2. Adesu

    Dtr and Rtd

    Adesu, Jun 14, 2004, in forum: AutoCAD
    Replies:
    3
    Views:
    321
    Adesu
    Jun 14, 2004
  3. jobbef

    convert from pro\E format in *.obj format

    jobbef, Feb 9, 2004, in forum: Pro/Engineer & Creo Elements/Pro
    Replies:
    0
    Views:
    331
    jobbef
    Feb 9, 2004
  4. Greg McLandsborough

    polar, dtr, rtd

    Greg McLandsborough, Jun 4, 2004, in forum: AutoCAD
    Replies:
    1
    Views:
    127
  5. domainadmin
    Replies:
    1
    Views:
    275
    Paul Jackson
    Aug 15, 2003
Loading...

Share This Page