Here in Australia it is well into the 21st and I raised my own glass last night, but for John McCarthy and most of my readers, it is the 20th of October right now. So this is the appropriate time to say Happy Birthday to LISP. Here’s to another 50 years of simple, compact, maintainable, efficient and elegant coding.
Category Archives: LISP
50 years of LISP
It is difficult to find an exact date for LISP’s birthday. It wasn’t so much born in an instant as it was gradually dragged out of the primordial slime during the heady days of late 50s computer research. What is known is that John McCarthy, LISP’s “father”, published a report in October 1958 about his new programming language aimed at providing artificial intelligence capabilities on the IBM 704 mainframe computer. That report, one of a series, was the first one to use the name LISP.
OOPSLA, a major annual conference on object-oriented programming, has decided to celebrate LISP’s 50th birthday on 20 October 2008. Practically everyone at that event is likely to be smarter, geekier and possibly even more pedantic than me. So for now I’m going to go with that date and raise a glass to LISP and John McCarthy in one week’s time.
John Walker’s almost-accidental but still inspired decision to add LISP to AutoCAD was, in my opinion, the most significant feature addition in AutoCAD’s history. There were many other feature additions without which AutoCAD would be a joke (e.g. blocks, undo/redo, dimensioning, polylines) but they were always going to happen anyway.
Adding LISP wasn’t like that. It wasn’t inevitable. It was an excellent example of Walker thinking outside the box, and it was the one thing that raised AutoCAD significantly above its competitors (yes, it had serious competitors once) at a time when the PC CAD market was still up for grabs.
The genius of this move was that instead of attempting to fill AutoCAD’s many feature holes, Autodesk could provide the tools that would let the users do that for themselves. The language was an ideal fit for a number of reasons, and users in droves started hole-filling with a vengeance. Without that boost to AutoCAD’s open architecture, the PC CAD market would have been a very different place. Autodesk itself may not even have survived into the 1990s, and I could have been writing this blog about Versacad, Computervision, or some other competitor.
Today, despite an unfortunate history of long periods of neglect from Autodesk, LISP remains the language of choice for most of my AutoCAD-related programming needs. There are exceptions, but I’ll usually first see if a given job can be done in LISP. If it can’t be done easily and well in LISP, then I will consider using one of the other available languages. For the sort of work I usually do, that doesn’t happen very often.
Why? I’ll explain my reasoning in a later post.
Autodesk discussion group alternatives
As I’m typing this, the Autodesk discussion groups are down for maintenance again. Let’s hope that when they come back up, some of the problems are fixed.
In the meantime, if you’re an AutoCAD user and have something to ask or say, where can you go? Here are a few suggestions.
- I like the AUGI forums. It’s an even more modern, more graphical and less space-efficient web interface than the new Autodesk one, but there’s a good community there and, hey, the search feature works. Mike Perry and colleagues run a tight ship, so please read the rules and be good.
- If you have something to tell Autodesk and want practically no restrictions in the way you say it, submit a new message on dear Autodesk, or vote for the existing messages you like. It’s looking a bit bare and empty at the moment, so go fill it up.
- As a Cadalyst person, it would be remiss of me to avoid mentioning the Cadalyst forums.
- The Swamp is biased heavily toward CAD programming, so if you have a LISP question then head there, but it also hosts general CAD discussion. In this community, you are expected to be courteous and professional.
- Old-timers like myself will remember that the CompuServe ACAD forum’s Take 5 section was carried over into the AutoCAD discussion groups. It was kept going for a few years before Autodesk felt it was getting out of hand and killed it. That community refused to be killed, and actually still flourishes for newsgroup (NNTP) users at the t5 dot dynip dot com server.
- R. K. McSwain suggests the CADTutor forums.
If you wish to point out any other sites I’ve missed, please let me know and if they’re relevant I’ll edit this post to include them.
While I was typing this, the Autodesk discussion groups came back up, but who knows how long that’s going to last?
Also while typing this I also received a phone call from a helpful Indian gentleman at Subscription Support (which was working fine as of yesterday). He asked for details about the broken search (it doesn’t find anything posted prior to the update), confirmed that it’s broken, and promised to inform the relevant department. That’s a much better response than the email I mentioned in my last post.
What is loaded at AutoCAD startup, and when?
Warning, CAD nerd stuff ahead. This is a long and technical post and if you’re using AutoCAD in a largely out-of-the-box state you probably won’t care about any of it.
If your modification of AutoCAD extends beyond the trivial, you may find it useful to know what AutoCAD loads, and in what order things are loaded. It is possible for LISP files in particular to tread on each other’s toes, so knowing what gets loaded when can be useful information for diagnosing such clashes. This post aims to provide that information. It uses AutoCAD 2009 as an example, but the same principles apply to all releases from AutoCAD 2006 onwards.
On startup, the first things AutoCAD loads are its CUI files. It first loads the Enterprise CUI file, then the Main CUI file, then any partial CUI files attached to the Main, then any partial CUI files attached to the Enterprise. I have no idea of the reasoning behind this slightly strange order, but there it is. The order of the partial CUIs loaded in each case is determined by the order in which they appear in the parent CUI files, which is determined by the order in which you attached them. If you don’t like this order, you can attach and reattach them in the CUI interface, or you can do the same thing much quicker with a text editor if you feel confident enough. If there are LISP files associated with these CUI files, they are not loaded yet. You’ll need to wait a few paragraphs for that.
Next, if you have created a file called acad.rx in AutoCAD’s search path, any ARX files listed in that file will be loaded. There are other ways in which developers can load their ARX files at startup, but I won’t go into that here.
Following that, the acad*.lsp files are loaded. First, Autodesk’s acad2009.lsp file is loaded. Next, if you have created a file called acad.lsp, that is loaded. These two files are only loaded at first startup, unless the ACADLSPASDOC system variable is set to 1, in which case the acad.lsp file is reloaded with each new drawing. Next comes Autodesk’s acad2009doc.lsp and any acaddoc.lsp file you may have created, in that order. These two files are loaded at startup and with every new drawing session.
It’s worth pointing out here that the acad200x.lsp and acaddoc200x.lsp files are Autodesk’s and are not intended to be modified by users. You can modify them, and adding things in there works fine, but updates and hotfixes can overwrite these files, leaving you to patch things up again afterwards. The acad.lsp and acaddoc.lsp files are yours, and that is where you are best advised to put your additions.
I hesitate to mention VBA because I have long avoided that development environment and my knowledge in that area is very limited, but if you’re a VBA developer and have created an acad.dvb file in AutoCAD’s search path, it gets loaded at this point.
Once the acad*.* files are loaded, then come any LISP files associated with the CUI files that were loaded at the beginning. For each CUI file, if there is a *.mnl file of the same name, that will be loaded first (*.mnl files are just *.lsp files renamed). After that, any LISP files that are specified in the CUI file will be loaded, in the order in which they appear in the CUI file itself. This order can be modified in the same ways that the partial CUI loading sequence can be modified; “delete” and “load” (detach and attach, really) the files within the CUI interface, or hack the CUI file with a text editor.
The CUI-associated LISP files are loaded as described in the above paragraph for each CUI file in turn, in the same order as the CUI files themselves: Enterprise, then Main, then partials to Main, then partials to Enterprise.
The Appload command provides a Startup Suite facility, where you can specify any number of files to load (*.arx, *.lsp, *.dvb, *.dbx, *.vlx or *.fas). If you have done so, those files are loaded at this point, in the order in which they appear in the Startup Suite list.
That’s all the actual loading done, but we’re not finished yet. At this point AutoCAD’s environment should be all ready to do pretty much anything, including things that modify the drawing database, including invoking commands. This was not true earlier on, so if you want to do things like change the drawing or run commands, this should be done using a startup routine rather than called directly at load time from any of the files loaded above.
If you’ve defined a VBA sub called AcadStartup(), it will be called now. If starting a new drawing, any sub called AcadDocument_Activate() will be called instead. The caveat about my VBA ignorance still applies here.
If a LISP function called (S::STARTUP) has been defined, it will be called next. Where could that be defined? Anywhere in any of the LISP files mentioned above, or in any LISP or other files that are loaded by any of those files, or by any files that are loaded by any of those files, and so on ad infinitum. It could even be defined in one of the ARX files loaded at any point. This would be unusual, but is quite possible.
If there are multiple (S::STARTUP) functions defined in various places, which one wins? Whichever one loaded last. That’s why the load order can be important, but it’s also why you should never have an unconditional (defun S::STARTUP …) definition in your LISP code. Instead, you should append your startup code to any existing (S::STARTUP) function. That way, your startup can cooperate with any others in your environment rather than walking all over it. If there is some interest in that subject, I can cover it in more detail in a future post.
In summary, here is the AutoCAD startup sequence:
A. CUI files loaded:
1. Enterprise
2. Main
3. Partials to Main
4. Partials to Enterprise
B. acad*.* files loaded:
1. Files listed in acad.rx
2. acad2009.lsp
3. acad.lsp
4. acad2009doc.lsp
5. acaddoc.lsp
6. acad.dvb
C. CUI-associated MNL and LSP files loaded:
1. Enterprise named MNL
2. Enterprise loaded LSP and MNL
3. Main named MNL
4. Main loaded LSP and MNL
5. Partials to Main named MNLs
6. Partials to Main loaded LSPs and MNLs
7. Partials to Enterprise named MNLs
8. Partials to Enterprise loaded LSPs and MNLs
D. Startup suite files loaded
E. Startup routines run:
1. AcadStartup() called (AutoCAD startup)
2. AcadDocument_Activate() called (Drawing startup)
3. (S::STARTUP) called
Autodesk University Session Voting
This year, the Autodesk University people are allowing you to vote on the various sessions (classes). Here’s the link:
AU 2008: Help Us Select the Sessions
If I can sort out a few practical details, I am hoping to attend this year as a speaker. I have submitted four session proposals. These are:
Customization and Programming
Be unfashionable in style with LISP and DCL – Introduction
Be unfashionable in style with LISP and DCL – Intermediate
Be unfashionable in style with LISP and DCL – Advanced
Business
How to make a great CAD blog for next to nothing
If you intend attending AU this year, I encourage you to vote for the sessions you would like to see presented.
Wiki for AutoLISP
Greg Robinson, who I had the pleasure of meeting at Autodesk some 11 years ago in the run-up to Release 14, has started a Wiki for AutoLISP and other AutoCAD-based source code. I’m a big fan of LISP in AutoCAD, so I’m happy to see this resource available for users.
It’s in its infancy right now, but if you pick the All Pages link you’ll see that there already dozens of routines available, one of which may help you with something you need to do. Here’s the link to the main page: