What is the Difference between Lisp , Common Lisp and AutoLisp?

What is the Difference between Lisp , Common Lisp and AutoLisp?

SanjoyNath
Advocate Advocate
8,285 Views
13 Replies
Message 1 of 14

What is the Difference between Lisp , Common Lisp and AutoLisp?

SanjoyNath
Advocate
Advocate

Dear Experts,

 

 

When i go through help guides for Lisp , i get several commands which i dont get in AutoLisp.When i try to use these commands it shows error in CAD command line

 

 

What are the list of commands in Lisp that AutoLisp dont support?

I have gone through 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/difference-between-visual-lisp-autol...

 

 

This is not talking anything about Lisp and Common Lisp

 

 

Sanjoy Nath
BIM Manager And Digital Lead (Structures Online)
BOOST, AR , VR ,EPM,IFC API,PDF API , CAD API ,Revit API , Advance Steel API
Founder of Geometrifying Trigonometry(C)
0 Likes
Accepted solutions (2)
8,286 Views
13 Replies
Replies (13)
Message 2 of 14

devitg
Advisor
Advisor

You SHALL NOT use Common LISP,  ACAD  only and sole , alone , etc, allow the LISP and Vlisp. Please use the VLIDE command. 

Type VLIDE at the command line . and the LISP editor will allow you to program  both in LISP and Vlisp 

 

Why you need to use Common LISP??

 

0 Likes
Message 3 of 14

SanjoyNath
Advocate
Advocate

Dear Experts,

 

I have some readymade libraries in Lisp which does Systems handling , windows handling , etc...

If we could call thouse libraries with Autolisp , then that could help us tp plot many graphs from the databases to directly on CAD

Sanjoy Nath
BIM Manager And Digital Lead (Structures Online)
BOOST, AR , VR ,EPM,IFC API,PDF API , CAD API ,Revit API , Advance Steel API
Founder of Geometrifying Trigonometry(C)
0 Likes
Message 4 of 14

devitg
Advisor
Advisor

What those readymade libraries , looks like??

 

 

0 Likes
Message 5 of 14

cadffm
Consultant
Consultant

By AutoLisp/Visuallisp you have access to COM/ACTIVEX interface, if you can make your functions

available via COM/ACTIVEX, you have a way between your CL and AutoLisp/VL.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/common-lisp/td-p/1357274

 

Is is really so hard stuff? Re-write the functions isn't an option?

What you are missing in AutoCAD(LISP)?

Sebastian

0 Likes
Message 6 of 14

john.uhden
Mentor
Mentor

I am gathering that his library of Lisp is code that contains functions unrecognized by AutoLisp/Visual Lisp.  Maybe if he knew what those functions did (how they work) he could duplicate them in AutoLisp.

Let me ask... if you knew no AutoLisp and you ran into code containing the mapcar function, wouldn't you have to research that function to find out how it works?

I just have no idea how to answer his question other than to say to research the Lisp language, which is I think exactly what he is doing.

John F. Uhden

Message 7 of 14

john.uhden
Mentor
Mentor

Sorry, Sebastian.  I had intended my reply to someone earlier in the thread.  Please don't take any offense or I'll break both your arms.  🙂

John F. Uhden

0 Likes
Message 8 of 14

martti.halminen
Collaborator
Collaborator
Accepted solution

 

Lisp is a family of programming languages, originated in 1958.

https://en.wikipedia.org/wiki/Lisp_(programming_language)

 

- When people refer to Lisp in an AutoCAD context, they are usually talking about the Lisp implementation in AutoCAD, which nowadays is called Visual Lisp. It used to be AutoLISP, but the name changed in AutoCAD 2000, or thereabouts when the ActiveX functionality (and some other stuff visible as functions with names starting with "vl") was added to the system. In practice both names are still used almost interchangeably, though sometimes separating the old and new programming styles (entget, entmake etc. in AutoLISP, vla- -functions in Visual Lisp). There is only one Lisp system in AutoCAD, so AutoLISP is just a subset of its functionality, not a separate implementation these days.

 

Common Lisp (usually abbreviated as CL) is the name of the current mainstream Lisp programming language, not related to AutoCAD in any way. There are several implementations, both commercial (Lispworks and Franz Allegro CL) and open-source (SBCL, CMU-CL, CLISP, CCL etc.)

 

Common Lisp is a far larger language than Visual Lisp, so it would be a much easier task to create a list of those things that they have in common. Back when there used to be printed documentation, the part about AutoLISP was 66 pages. A book about CL at about same detail level is about 1000 pages, it has a 60 -page index.

- even some parts that have the same names behave somewhat differently.

 

The full language definition is available online, see for example http://www.lispworks.com/documentation/HyperSpec/Front/index.htm

 

As a short list, nothing in CL referring to object oriented programming (CLOS), macroes, arrays, vectors, hash tables, structures, packages, exceptions and conditions (error handling), streams, imaginary numbers,  readtables, multiple return values, modifying list contents in-situ, non-local exits, user-defined types or rational numbers has any corresponding part in Visual Lisp.

 

-- 

Message 9 of 14

martti.halminen
Collaborator
Collaborator
Accepted solution

@SanjoyNath wrote:

 

I have some readymade libraries in Lisp which does Systems handling , windows handling , etc...

If we could call thouse libraries with Autolisp , then that could help us tp plot many graphs from the databases to directly on CAD


Unless those libraries are written in an extremely restricted subset of CL (and you have the sources), re-implementing them in Visual Lisp is practically impossible. So, to call them, you need to run them in a CL system and communicate with that. There are some alternatives:

 

A) Compile your CL stuff into a .dll and link it into AutoCAD

- the commercial CL implementations can do this, not sure about the open-source ones.

- can't call directly from Visual Lisp, needs some C++ work to make it available

 

B) Communicate between AutoCAD and a separate CL program using ActiveX

- only available on the commercial CL implementations

- ill-documented and occasionally unstable on the AutoCAD side

 

C) Communicate between AutoCAD and a separate CL program using sockets

- Visual Lisp doesn't understand sockets, so you'd have to do that part via C++ or C#.

 

D) Communicate between AutoCAD and a separate CL program using files

- just write the results from your library call into a file as a list all written on one line, and read it with Visual Lisp using (read (read-line filehandle))

 

--

 

Message 10 of 14

john.uhden
Mentor
Mentor
I still think of AutoLisp and Visual Lisp separately, though they
cohabitate just fine. It was Peter Petrov who developed Vital Lisp (sold
separately) for R14, and Autodesk eventually bought it from him, keeping
most of the syntax intact.

John F. Uhden

0 Likes
Message 11 of 14

SanjoyNath
Advocate
Advocate

Dear Martti,

 

To do all these , i directly write in QT, C++ Object Arx , and also in c#

It is concern to reuse lisp codes.OK let me try these Technics


@martti.halminen wrote:

@SanjoyNath wrote:

 

I have some readymade libraries in Lisp which does Systems handling , windows handling , etc...

If we could call thouse libraries with Autolisp , then that could help us tp plot many graphs from the databases to directly on CAD


Unless those libraries are written in an extremely restricted subset of CL (and you have the sources), re-implementing them in Visual Lisp is practically impossible. So, to call them, you need to run them in a CL system and communicate with that. There are some alternatives:

 

A) Compile your CL stuff into a .dll and link it into AutoCAD

- the commercial CL implementations can do this, not sure about the open-source ones.

- can't call directly from Visual Lisp, needs some C++ work to make it available

 

B) Communicate between AutoCAD and a separate CL program using ActiveX

- only available on the commercial CL implementations

- ill-documented and occasionally unstable on the AutoCAD side

 

C) Communicate between AutoCAD and a separate CL program using sockets

- Visual Lisp doesn't understand sockets, so you'd have to do that part via C++ or C#.

 

D) Communicate between AutoCAD and a separate CL program using files

- just write the results from your library call into a file as a list all written on one line, and read it with Visual Lisp using (read (read-line filehandle))

 

--

 




Sanjoy Nath
BIM Manager And Digital Lead (Structures Online)
BOOST, AR , VR ,EPM,IFC API,PDF API , CAD API ,Revit API , Advance Steel API
Founder of Geometrifying Trigonometry(C)
Message 12 of 14

Germain.Braaten
Community Visitor
Community Visitor
Is it possible to use AutoLISP & Visial LISP knowledge in a Common LISP world?
0 Likes
Message 13 of 14

cadffm
Consultant
Consultant

@Germain.Braaten  schrieb:
Is it possible to use AutoLISP & Visial LISP knowledge in a Common LISP world?

Yes, but "using knowledge" doesn't mean you can write Common LISP programs without additional lession.

It means:  You'll get used to it faster than someone who can't program AutoLISP yet.

Sebastian

0 Likes
Message 14 of 14

martti.halminen
Collaborator
Collaborator

@Germain.Braaten wrote:
Is it possible to use AutoLISP & Visial LISP knowledge in a Common LISP world?

First you'll have to remember that CL knows nothing about AutoCAD, so anything referring to AutoCAD commands, internals, CUI or DCL is irrelevant there.

 

The other point is that CL is a much larger language, so often things get done differently there; for example nobody bothers creating variable names at runtime since the language got hash tables about 40 years ago.

AutoLISP has 6 data types, CL has 17 if I remember correctly.

 

- Some of the VL-functions are borrowed from CL functions with the same name (without the vl- prefix): every, some,  list*, remove-if-not, princ-to-string etc.

 

While the basic list handling and mathematical operations are generally same, there are some differences which will cause problems.

For example:

 

AutoLISP:

 

_$ (< foo 6)
T

 

Common Lisp:

 

CLO 8 > (< foo 6)

The variable FOO is unbound.
[Condition of type UNBOUND-VARIABLE]

Restarts:
0: [NIL] Try evaluating FOO again.
1: [USE-VALUE] Specify a value to use this time instead of evaluating FOO.
2: [SET] Specify a value to set FOO to.
3: [FUNCALL-SYMBOL] Return the result of calling (FOO) instead.
4: [ABORT] Return to top loop level 0.
5: [ABORT] Quit process.

Backtrace:
0: (CONDITIONS::CONDITIONS-ERROR :INVISIBLEP T #<UNBOUND-VARIABLE 40200250DB> NIL)
1: (ERROR #<UNBOUND-VARIABLE 40200250DB>)
2: (CONDITIONS::UNBOUND-SYMBOL-ERROR-INTERNAL :INVISIBLEP T FOO)
3: (SYSTEM::%EVAL FOO)
4: (SYSTEM::%INVOKE :INVISIBLEP T)
5: (SYSTEM::%EVAL (< FOO 6))
6: (EVAL (< FOO 6))

 

And that hides another dangerous difference:

 

AutoLISP:

_$ (< nil 6)
T

 

CL:

CLO 9 > (< nil 6)

Arithmetic error in < of (NIL 6): Arguments must be real numbers.
[Condition of type CONDITIONS::ARITHMETIC-TYPE-ERROR-WITH-MESSAGE]

 

AutoLISP:

_$ (read "qwETY.123456")

QWETY

 

CL:

CLO 11 > (read-from-string "qwETY.123456")
QWETY.123456

 

AutoLISP:

_$ (or nil nil 8 nil)
T

 

CL:

CLO 12 > (or nil nil 8 nil)
8

 

 

 

And so on. There are about a dozen similar traps I have so far encountered.