Visual Lisp vs Auto Lisp

Visual Lisp vs Auto Lisp

Anonymous
Not applicable
1,382 Views
23 Replies
Message 1 of 24

Visual Lisp vs Auto Lisp

Anonymous
Not applicable
Hello,
What is the difference between visual lisp and auto lisp?
George
0 Likes
1,383 Views
23 Replies
Replies (23)
Message 2 of 24

Anonymous
Not applicable
AutoLISP is what came with R14 and earlier. Visual LISP is what comes with
R2000 and later. VLisp includes all of the AutoLISP functions, plus a whole
lot more.
___

"gpal1" wrote in message
news:f0bfd9a.-1@WebX.maYIadrTaRb...
>
> What is the difference between visual lisp and auto lisp?
0 Likes
Message 3 of 24

Anonymous
Not applicable
The main difference is that functions defined with DEFUN
are now a new datatype, USUBRs, and not lists as before.

Main consequence of this has to do with S::STARTUP
function redefinition. It used to be done with append,
but it can't now since USUBR is an atomic type. The
addition of your subroutine to the startup processing
can now be done with this utility function:

(defun PlugIntoStartup (MyFuncSym) ;by Vladimir Nesterovsky
"to be called with quoted function name"
(eval (list
'defun 'S::StartUp ()
(if S::StartUp (list (list 'quote S::StartUp)))
(list MyFuncSym))))

so if you have all your startup code packed into one routine

(defun my-startup ()
(alert "My Startup"))

you make it work with the call

(PlugIntoStartup 'my-startup)

inside your acaddoc.lsp for instance.

--
Have fun, 🙂
Vlad http://vnestr.tripod.com/


gpal1 wrote in message
news:f0bfd9a.-1@WebX.maYIadrTaRb...
> Hello,
> What is the difference between visual lisp and auto lisp?
> George
>
>
0 Likes
Message 4 of 24

Anonymous
Not applicable
On a side note, use defun-q to define your S::STARTUP and it will still be a
list, not compiled like DEFUN would have it. I'm sure you already knew,
Vladimir, but others may not. :^)
--

Regards,
Eric S.
A2k/W2k
0 Likes
Message 5 of 24

Anonymous
Not applicable
Problem is, when you come to redefine the S::STARTUP function,
it might be defined with defun-q or defun, you don't know. You can
of course check the type of s::startup, but you may just as well use
the code that works in both cases. Defun-q is good only for the
situation where you have absolute and exclusive control of your
computer and all the 3rd party programs installed in it.

--
Vlad http://vnestr.tripod.com/


Eric Schneider wrote in message
news:144E6C5DA40163465F3BEAA7CE684229@in.WebX.maYIadrTaRb...
> On a side note, use defun-q to define your S::STARTUP and it will still be
a
> list, not compiled like DEFUN would have it. I'm sure you already knew,
> Vladimir, but others may not. :^)
> --
>
> Regards,
> Eric S.
> A2k/W2k
>
>
0 Likes
Message 6 of 24

Anonymous
Not applicable
I would hope *all* developers would have the courtesy to use DEFUN-Q on
S::STARTUP functions so they don't break every other developers and our own
personal S::STARTUPs, but unfortunately, as you point out, they may not.
--

Regards,
Eric S.
A2k/W2k
0 Likes
Message 7 of 24

Anonymous
Not applicable
Very intriguing function. It seems to point out that the USUBR value
is not lost when the symbol s:startup is redefined. The function you have
written could have a more general use to add expressions to any USUBR
function with no arguments. The technique could not be used to expand
a function that had arguments. For that, a defun-q must be used.

(defun appendfun (fun nextfun)
(eval (list 'defun fun ()
(if (eval fun)
(list (list 'quote (eval fun))))
(list nextfun))))

But on a side note, why have the s::startup function anyway? It seems like
a holdover from R14. The same effect could be accomplished by merely
having the expressions listed in ACADDOC.LSP by themselves.
It seems to me that its only possible use is to localize some variables
(but that is rarely done). After all, ACADDOC.LSP is really in a sense
the s::startup function.

Thanks Vladimir. Your posts are always educational.

Doug



"Vladimir Nesterovsky" wrote in message
news:C1899F9A97FD59BDCBEFC5A277835B9E@in.WebX.maYIadrTaRb...
> The main difference is that functions defined with DEFUN
> are now a new datatype, USUBRs, and not lists as before.
>
0 Likes
Message 8 of 24

Anonymous
Not applicable
"Doug Broad" wrote in message
news:BD313156F184F5D0B21068DDA3AA54A4@in.WebX.maYIadrTaRb...
> But on a side note, why have the s::startup function anyway? It seems
like
> a holdover from R14. The same effect could be accomplished by merely
> having the expressions listed in ACADDOC.LSP by themselves.
> It seems to me that its only possible use is to localize some variables
> (but that is rarely done). After all, ACADDOC.LSP is really in a sense
> the s::startup function.

Except that (command) statements better be in S::StartUp (not that *I* use
them...).
0 Likes
Message 9 of 24

Anonymous
Not applicable
Hi Robert,
It doesn't seem to matter in 2000 and 2002. I've tested it.

Doug


"R. Robert Bell" wrote in message news:58DCCDFD18C663EF6AF1673C6A63CC3A@in.WebX.maYIadrTaRb...
> "Doug Broad" wrote in message
> news:BD313156F184F5D0B21068DDA3AA54A4@in.WebX.maYIadrTaRb...
> > But on a side note, why have the s::startup function anyway? It seems
> like
> > a holdover from R14. The same effect could be accomplished by merely
> > having the expressions listed in ACADDOC.LSP by themselves.
> > It seems to me that its only possible use is to localize some variables
> > (but that is rarely done). After all, ACADDOC.LSP is really in a sense
> > the s::startup function.
>
> Except that (command) statements better be in S::StartUp (not that *I* use
> them...).
>
>
0 Likes
Message 10 of 24

Anonymous
Not applicable
That's what *I* get for not...


The startup LISP files (acad.lsp, acaddoc.lsp, and .mnl) all load into
memory before the drawing is completely initialized. Typically, this does
not pose a problem, unless you want to use the command function, which is
not guaranteed to work until after a drawing is initialized.


That is from the Customization Guide...

--
R. Robert Bell, MCSE
www.AcadX.com


"Doug Broad" wrote in message
news:52452BF5D52AEC378A75C7AF60FF492F@in.WebX.maYIadrTaRb...
> Hi Robert,
> It doesn't seem to matter in 2000 and 2002. I've tested it.
>
> Doug
>
>
> "R. Robert Bell" wrote in message
news:58DCCDFD18C663EF6AF1673C6A63CC3A@in.WebX.maYIadrTaRb...
> > "Doug Broad" wrote in message
> > news:BD313156F184F5D0B21068DDA3AA54A4@in.WebX.maYIadrTaRb...
> > > But on a side note, why have the s::startup function anyway? It seems
> > like
> > > a holdover from R14. The same effect could be accomplished by merely
> > > having the expressions listed in ACADDOC.LSP by themselves.
> > > It seems to me that its only possible use is to localize some
variables
> > > (but that is rarely done). After all, ACADDOC.LSP is really in a
sense
> > > the s::startup function.
> >
> > Except that (command) statements better be in S::StartUp (not that *I*
use
> > them...).
> >
> >
>
>
0 Likes
Message 11 of 24

Anonymous
Not applicable
Visual LISP is available for R14.

"Paul Turvill" wrote in message news:798CCC7540EEEE87AE5FDDC7D6A17377@in.WebX.maYIadrTaRb...
> AutoLISP is what came with R14 and earlier. Visual LISP is what comes with
> R2000 and later. VLisp includes all of the AutoLISP functions, plus a whole
> lot more.
> ___
0 Likes
Message 12 of 24

Anonymous
Not applicable
> That's what *I* get for not...

🙂

*I* 😉 had a problem about a year ago when I started transitioning between
R14 and R2000, having used acad.lsp with a s::startup from "long ago." It no
longer worked in 2000 since it did not load when each subsequent drawing
loaded. I then tried to add a second s::startup in acaddoc.lsp but it conflicted
with the one in acad.lsp. So I added a check in my acad.lsp, (wanting to
maintain backward compatibility), that tested the version of autocad and only
defined s::startup if R14 and earlier. For almost a year, I have had command
function statements from beginning to end in the acaddoc.lsp and have yet
to have a problem. I realize that Autodesk does not "guarantee" that command
functions will work except in the "post initialization" s::startup routine but
I have not had a problem even though I have opened over 10, 000 drawings
since I commented out the "(defun s::startup ()." in acaddoc.lsp

If I ever go back to using it, I will be sure to use Vladimir's function. *I* do
appreciate the warning, though, Robert. 🙂

Doug


"R. Robert Bell" wrote in message news:EABC0DBAB2FF1050D6A2455DABDADFDB@in.WebX.maYIadrTaRb...
> That's what *I* get for not...
0 Likes
Message 13 of 24

Anonymous
Not applicable
Exactly. Why be dependent on someone's courtesy
when you don't have to? 🙂 🙂


Eric Schneider wrote in message
news:E0538FB98385430802B9B5A9682BAF82@in.WebX.maYIadrTaRb...
> I would hope *all* developers would have the courtesy to use DEFUN-Q on
> S::STARTUP functions so they don't break every other developers and our
own
> personal S::STARTUPs, but unfortunately, as you point out, they may not.
> --
>
> Regards,
> Eric S.
> A2k/W2k
>
>
0 Likes
Message 14 of 24

Anonymous
Not applicable
Yeah, where would we start? With Microsloth? ;^)

--
R. Robert Bell, MCSE
www.AcadX.com


"Vladimir Nesterovsky" wrote in message
news:36F0C1ABE0895B832310677FAFAA21CB@in.WebX.maYIadrTaRb...
> Exactly. Why be dependent on someone's courtesy
> when you don't have to? 🙂 🙂
0 Likes
Message 15 of 24

Anonymous
Not applicable
Thanks, Doug. 🙂

I think this technique can be used to hook up any function,
with any number of arguments; you'd only have to know
their number in advance, and I've yet to find out how it can
be done.

Can you think of some way to find out the "arity" of a Vlisp
subroutine? ("arity" is a number of arguments it's expecting).
This can be useful in lisp profiling for run-time function redefinition.

(defun appendfun (fun nextfun / args)
"call with both names quoted"
(setq args '(a1 a2 a3)) ; 3-arguments case
(eval (list
'defun fun args ; or DEFUN-Q can be used here just as well
(cons (list 'quote (vl-symbol-value fun)) args)
(cons (list 'quote (vl-symbol-value nextfun)) args)
)))

test:
(defun foo(a b c) (print (+ a b (* 2 c))) (princ))
(defun bar(a b c) (- (+ a b) c))
(appendfun 'foo 'bar) ;=> redefine the foo function.

Command: (foo 1 2 3)
9
Command: (bar 1 2 3) 0
Command: (appendfun 'foo 'bar) FOO
Command: (foo 1 2 3)
9 0

--
Have fun, 🙂
Vlad http://vnestr.tripod.com/
(define (list . args) args)


Doug Broad wrote in message
news:BD313156F184F5D0B21068DDA3AA54A4@in.WebX.maYIadrTaRb...
> Very intriguing function. It seems to point out that the USUBR value
> is not lost when the symbol s:startup is redefined. The function you have
> written could have a more general use to add expressions to any USUBR
> function with no arguments. The technique could not be used to expand
> a function that had arguments. For that, a defun-q must be used.
>
> (defun appendfun (fun nextfun)
> (eval (list 'defun fun ()
> (if (eval fun)
> (list (list 'quote (eval fun))))
> (list nextfun))))
>
> But on a side note, why have the s::startup function anyway? It seems
like
> a holdover from R14. The same effect could be accomplished by merely
> having the expressions listed in ACADDOC.LSP by themselves.
> It seems to me that its only possible use is to localize some variables
> (but that is rarely done). After all, ACADDOC.LSP is really in a sense
> the s::startup function.
>
> Thanks Vladimir. Your posts are always educational.
>
> Doug
>
>
>
> "Vladimir Nesterovsky" wrote in message
> news:C1899F9A97FD59BDCBEFC5A277835B9E@in.WebX.maYIadrTaRb...
> > The main difference is that functions defined with DEFUN
> > are now a new datatype, USUBRs, and not lists as before.
> >
>
0 Likes
Message 16 of 24

Anonymous
Not applicable
All we need is to re-write ACAD to run under Linux. >:->


R. Robert Bell wrote in message
news:A414B51BF574B1958911FB3897FC765B@in.WebX.maYIadrTaRb...
> Yeah, where would we start? With Microsloth? ;^)
>
> --
> R. Robert Bell, MCSE
> www.AcadX.com
>
>
> "Vladimir Nesterovsky" wrote in message
> news:36F0C1ABE0895B832310677FAFAA21CB@in.WebX.maYIadrTaRb...
> > Exactly. Why be dependent on someone's courtesy
> > when you don't have to? 🙂 🙂
0 Likes
Message 17 of 24

Anonymous
Not applicable
Hi Vladimir,
I started to sent you this second function this morning after I thought about
what I'd said about it only working with no arguments. I couldn't get
it to work right before the work-a-day rush hit so it had to wait.
This was the version I was thinking of. It allows for the first function
to be undefined, serving as the wrapper for succeeding calls. Functions
could be added one by one or with mapcar or apply

;use with all arguments quoted
;fun and nextfun are symbols and args1 and args2 are quoted argument lists
(defun appendfun (fun args1 nextfun args2)
(eval (list 'defun
fun
args1
(if (eval fun)
(cons (list 'quote (eval fun)) args1))
(cons (list 'quote (eval nextfun)) args2))))


;Example use
(appendfun 'dummy '(a b c) 'myfun '(a b c))
or
(appendfun 'dummy '(a b c) 'myfun '(a b))
or
(mapcar '(lambda (nf args)(appendfun 'fun '(a b c) nf args))
'(fun1 fun2 fun3)
'((a b c) '(b c) '(a b)))

Is there an advantage in using the vl-symbol-value function over
the eval function?

Finding the "arity" was a big advantage of the old method of defun
creating a list. The number of arguments used to be (as you know)

(length (cadr fun))

Now with all of the functions being stored as USUBR's that functionality
is lost. I'm not sure how to determine the arity other than to use
vla-catch-all-apply to possibly keep feeding dummy argument lists until
the function no longer returns an incorrect argument number error.
Seems like there should be something like the atomlist of old to keep
track of function argument type and number and report. I guess it's not
much of a loss since you couldn't really use a function very intelligently
unless you knew what it's arguments should be.

I hated to see the loss of the list structure until I learned that A'desk had
provided DEFUN-Q. It was the beauty of the interpreted language that
programs could be data and could rewrite themselves. The addition of
VLIDE and DEFUN-Q more than made up for the loss.

Thanks again for your response Vladimir.

Doug


"Vladimir Nesterovsky" wrote in message
news:B8C9BA096C1ECC57DDC631DC5AE00EBC@in.WebX.maYIadrTaRb...
> Thanks, Doug. 🙂
>
> I think this technique can be used to hook up any function,
> with any number of arguments; you'd only have to know
> their number in advance, and I've yet to find out how it can
> be done.
>
> Can you think of some way to find out the "arity" of a Vlisp
> subroutine? ("arity" is a number of arguments it's expecting).
> This can be useful in lisp profiling for run-time function redefinition.
>
> (defun appendfun (fun nextfun / args)
> "call with both names quoted"
> (setq args '(a1 a2 a3)) ; 3-arguments case
> (eval (list
> 'defun fun args ; or DEFUN-Q can be used here just as well
> (cons (list 'quote (vl-symbol-value fun)) args)
> (cons (list 'quote (vl-symbol-value nextfun)) args)
> )))
>
> test:
> (defun foo(a b c) (print (+ a b (* 2 c))) (princ))
> (defun bar(a b c) (- (+ a b) c))
> (appendfun 'foo 'bar) ;=> redefine the foo function.
>
> Command: (foo 1 2 3)
> 9
> Command: (bar 1 2 3) 0
> Command: (appendfun 'foo 'bar) FOO
> Command: (foo 1 2 3)
> 9 0
>
> --
> Have fun, 🙂
> Vlad http://vnestr.tripod.com/
> (define (list . args) args)
>
0 Likes
Message 18 of 24

Anonymous
Not applicable
Vladimir,

Here's a kludgy approach to arity. Can you think of a better way?
This really should be named MinArity since some built in functions
have a flexible number of arguments. Can you think of a function
definitions for Fixed-Arity-P or for Max-Arity or perhaps Arity-OK?

(defun arity (fun / rv al i);D. C. Broad, Jr. 2002
;rv - return val, al - arg list, i - # of args
(setq i 0)
(while
(and
(vl-catch-all-error-p
(setq rv (vl-catch-all-apply fun al)))
(= "too few arguments" (vl-catch-all-error-message rv)))
(setq al (cons 'a al) i (1+ i)))
i)

;Example
(defun myfun (a b c) (princ (+ a b c)))
(arity 'myfun)
3

Doug

"Vladimir Nesterovsky" wrote in message
news:B8C9BA096C1ECC57DDC631DC5AE00EBC@in.WebX.maYIadrTaRb...

> Can you think of some way to find out the "arity" of a Vlisp
> subroutine? ("arity" is a number of arguments it's expecting).
> This can be useful in lisp profiling for run-time function redefinition.
0 Likes
Message 19 of 24

Anonymous
Not applicable
You're on our way to something here! If I fall asleep, wake me up when you're done.

--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juhden@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711


"Doug Broad" wrote in message news:8431D33A77A628F4B6811DD27B8AE07A@in.WebX.maYIadrTaRb...
> Vladimir,
>
> Here's a kludgy approach to arity. Can you think of a better way?
> This really should be named MinArity since some built in functions
> have a flexible number of arguments. Can you think of a function
> definitions for Fixed-Arity-P or for Max-Arity or perhaps Arity-OK?
>
> (defun arity (fun / rv al i);D. C. Broad, Jr. 2002
> ;rv - return val, al - arg list, i - # of args
> (setq i 0)
> (while
> (and
> (vl-catch-all-error-p
> (setq rv (vl-catch-all-apply fun al)))
> (= "too few arguments" (vl-catch-all-error-message rv)))
> (setq al (cons 'a al) i (1+ i)))
> i)
>
> ;Example
> (defun myfun (a b c) (princ (+ a b c)))
> (arity 'myfun)
> 3
>
> Doug
>
> "Vladimir Nesterovsky" wrote in message
> news:B8C9BA096C1ECC57DDC631DC5AE00EBC@in.WebX.maYIadrTaRb...
>
> > Can you think of some way to find out the "arity" of a Vlisp
> > subroutine? ("arity" is a number of arguments it's expecting).
> > This can be useful in lisp profiling for run-time function redefinition.
>
>
>
0 Likes
Message 20 of 24

Anonymous
Not applicable
Hi John,

Come on now. Based on what you've contributed, you could
write those little functions while standing on your head. I did go
to bed late but was developing a function to draw dimensioned
elevations and plans of adjustable shelves using K&V 182/82
brackets & standards.

I'll add some more functions if no one else contributes them
before dark. I'll wake you up then. Thanks for the encouragement.

Doug



"John Uhden" wrote in message news:E65858AA69B7E772E9BD387B8BA9370D@in.WebX.maYIadrTaRb...
> You're on our way to something here! If I fall asleep, wake me up when you're done.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> [ mailto:juhden@cadlantic.com ]
> [ http://www.cadlantic.com ]
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
>
>
> "Doug Broad" wrote in message news:8431D33A77A628F4B6811DD27B8AE07A@in.WebX.maYIadrTaRb...
> > Vladimir,
> >
> > Here's a kludgy approach to arity. Can you think of a better way?
> > This really should be named MinArity since some built in functions
> > have a flexible number of arguments. Can you think of a function
> > definitions for Fixed-Arity-P or for Max-Arity or perhaps Arity-OK?
> >
> > (defun arity (fun / rv al i);D. C. Broad, Jr. 2002
> > ;rv - return val, al - arg list, i - # of args
> > (setq i 0)
> > (while
> > (and
> > (vl-catch-all-error-p
> > (setq rv (vl-catch-all-apply fun al)))
> > (= "too few arguments" (vl-catch-all-error-message rv)))
> > (setq al (cons 'a al) i (1+ i)))
> > i)
> >
> > ;Example
> > (defun myfun (a b c) (princ (+ a b c)))
> > (arity 'myfun)
> > 3
> >
> > Doug
> >
> > "Vladimir Nesterovsky" wrote in message
> > news:B8C9BA096C1ECC57DDC631DC5AE00EBC@in.WebX.maYIadrTaRb...
> >
> > > Can you think of some way to find out the "arity" of a Vlisp
> > > subroutine? ("arity" is a number of arguments it's expecting).
> > > This can be useful in lisp profiling for run-time function redefinition.
> >
> >
> >
0 Likes