Jump to content
Bill Tillman

What's With QUOTE in the Array

Recommended Posts

Bill Tillman

Some other developers here are sending some variables with values into the project I'm working on from C#.NET code. It looks simple but something I did not expect is happening.

 

(setq the_array '('(1 "R" 0 1) '(1 "L" 0 1) '(0 "L" 0 1) '(0 "R" 0 1) '(1 "R" 1 1) '(1 "L" 1 1)))

If I examine the value of this variable called the_array it will show this:

((QUOTE (1 "R" 0 1)) (QUOTE (1 "L" 0 1)) (QUOTE (0 "L" 0 1)) (QUOTE (0 "R" 0 1)) (QUOTE (1 "R" 1 1)) (QUOTE (1 "L" 1 1)))
I wasn't expecting the word "QUOTE" to show up in the array. I'm going to parse this text to do some drawing tasks so just deleting this text from the string I think I can handle. I'd like to know why it shows up in the first place. I think this guy's attempt to form a list of lists is not quite right.

 

By removing the leading apostrophes I able to get the "QUOTE" text out of the value, but I have to admit I wasn't expecting this to happen. Nor were the other developers. And to be honest, I don't really need the " " around the text items in this either. So I'm going to change their input slightly to make it easier to parse this list of lists.

Share this post


Link to post
Share on other sites
Lee Mac

The apostrophe or single quote is a shorthand equivalent for the AutoLISP quote function, therefore, by quoting a list which contains single quotes, you will see the AutoLISP quote function appear as the quoted list is a literal expression and hence is not evaluated. This is no different to quoting a list containing any other AutoLISP function or symbol. Since the entire list is already quoted as a literal expression, the quotes within the list are redundant - see here for more information.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×