Jump to content

What's With QUOTE in the Array


Bill Tillman

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...