Page 1 of 1

### (setq 'a 3), what does it mean?

Posted: Tue Aug 12, 2014 6:00 pm
(setq a 2) => 2
(setq 'a 3) => 3
(eval a) => 2
(eval 'a) => 2
(eval ''a) => a

(setq a 2) equivalent to (set 'a 2)
(setq 'a 3) equivalent to (set ''a 3)?
but result is:
(set ''a 3) =>
ERR: symbol expected in function set : ''a

### Re: (setq 'a 3), what does it mean?

Posted: Tue Aug 12, 2014 6:22 pm
Hello,

I would expect that (setq 'a 3) should throw the same error as with (set ''a 3).

Regards

### Re: (setq 'a 3), what does it mean?

Posted: Tue Aug 12, 2014 6:53 pm
(setq 'a 2) will do in-place modification of symbol a. For more examples see the last chapter on this page: http://www.newlisp.org/index.cgi?Closures .

Code: Select all
`> (setq 'a 2)2> anil> (define (foo) (setq 'a 2))(lambda () (setq 'a 2))> (foo)2> foo(lambda () (setq '2 2))> `

### Re: (setq 'a 3), what does it mean?

Posted: Tue Aug 12, 2014 7:17 pm
psilwen wrote:(setq 'a 3) equivalent to (set ''a 3)?

Yes!^h^h^h^h
No. See Lutz's comment above. (Surprised me, btw. :))

psilwen wrote:but result is:
(set ''a 3) =>
ERR: symbol expected in function set : ''a

Yes, this is also correct, because that code induces a type error. set's first argument should be a symbol, but ''a (which can be thought of as shorthand for (quote (quote a))) evaluates to (quote a) which is of type quote, not symbol.

### Re: (setq 'a 3), what does it mean?

Posted: Wed Aug 13, 2014 6:20 pm

### Re: (setq 'a 3), what does it mean?

Posted: Wed Aug 13, 2014 10:44 pm
Yes, this is also correct, because that code induces a type error. set's first argument should be a symbol, but ''a (which can be thought of as shorthand for (quote (quote a))) evaluates to (quote a) which is of type quote, not symbol.

Whilst set versus setq is not on my list of confusions, the pair ' versus quote is, and usually I manage to ignore the existence of the quote word. But, with TedWhalter half-way there, I thought it worth to point out that apparently no phrase without ' (directly or indirectly) in it will make the quote? predicate true.

Indeed, the explanation is clear and valid and sensible, but maybe a bit liberal on the use of the word "type", because (quote (quote a)) as well as '(quote a) make list? true and quote? false, wherease both (quote 'a) as well as ''a make list? false and quote? true.

### Re: (setq 'a 3), what does it mean?

Posted: Thu Aug 14, 2014 12:05 am
ralph.ronnquist wrote:Whilst set versus setq is not on my list of confusions, the pair ' versus quote is, and usually I manage to ignore the existence of the quote word. But, with TedWhalter half-way there, I thought it worth to point out that apparently no phrase without ' (directly or indirectly) in it will make the quote? predicate true.

Yes, I did not expect this.

Code: Select all
`> (quote? ''x)true> (quote? (quote (quote x)))nil`

Head hurty. Tommy no likey. :)

### Re: (setq 'a 3), what does it mean?

Posted: Thu Aug 14, 2014 12:39 am
The thing I like the most about newLISP is that it has the least amount of "surprise" compared to other Lisps. And my ideas of "surprise" come from my C/shell/Unix background.

So, with the recent addition to the get-string function, I found myself again "surprised"... because the "chunk" size changes if you put the magic values of '\000\000' or '\000\000\000\000' in as delimiters. I feel like the less surprising thing would be to have get-bytes be raw data, and get-string be for getting strings of characters, no matter what the format.

Principle of Least Surprise. Makes my head feel clear and powerful.

Lately, I find myself getting more and more surprised. Every surprise means a gotcha, means yet another bit of state to hold in my head when programming.

### Re: (setq 'a 3), what does it mean?

Posted: Thu Aug 14, 2014 5:21 am
yes, sometimes some features of newlisp make me confusion.

for instance, in-place modification
Code: Select all
`(define (myinc)    (inc 0))(myinc) => 1myinc = > (lambda () inc 1)(myinc) => 2myinc => (lambda () inc 2)`

of course, this feature be really good. Just I've never seen in other languages.

i am learning newlisp in effort.

thanks all.

by the way,

1) i knowns win32demo.lsp. but is there win32gui module written using newlisp FOOP?

2) how to uncompress http gzip stream in memory with zlib? who has complete example of it. code of newlisp, not c/c++

i want to extract HTTP headers, such as Cookie..., and HTTP Body, but "get-url" cannot do it for me. I had to write my own one.

but i don't know how to do :(

in xmlhttp,we can do

make things so simple.

Does any suggestion? more detail more well.

### Re: (setq 'a 3), what does it mean?

Posted: Thu Aug 14, 2014 2:05 pm
quote and are not the same. The quote is a function executed at run-time the gets resolved at reader/compile time.

Before evaluation (quote x) is a list expression but ‘x is a quoted x. Therefore:
Code: Select all
`; one is a quoted symbol the other a list:(quote? ''x) => true(list? '(quote x)) => true; on the top level both evaluate to the same:(= (quote 'x) ''x) => true(= (quote (quote x)) '(quote x)) => true; and(quote? (quote 'x)) => true; but(= '(quote x) ''x) => nil; and(quote? '(quote x)) => nil`

On the level of evaluation both do the same, which is creating a do-nothing evaluation shield.

### Re: (setq 'a 3), what does it mean?

Posted: Thu Aug 14, 2014 6:44 pm
That sounds a lot clearer. Guess there was some Paul Graham macro tutorial stuff still rattling around in my brain. The way Paul Graham taught it, ' actually is a macro that expands to (quote). And in newLisp, it behaves a little bit like a macro, even though there are no Common Lisp style macros.

### Re: (setq 'a 3), what does it mean?

Posted: Fri Aug 15, 2014 5:39 am
psilwen wrote:
2) how to uncompress http gzip stream in memory with zlib? who has complete example of it. code of newlisp, not c/c++

Maybe you can use gunzip?

Code: Select all
`(exec "gunzip -c" gzipped-string)`