Page 1 of 1

variable $it not set - updating itn book

Posted: Tue Dec 06, 2011 12:22 pm
by conan
I found a reference to variable $it set by setf in Introduction to newlisp book, in the chapter on strings, http://en.wikibooks.org/w/index.php?tit ... ng_strings

which doesn't exist in the manual nor works in v10.3.3.

I was about to remove the mention, but then decided to ask first in here just in case there's another way to achieve the same results. I mean to operate on the character selected by setf and use that result as the input to the same setf.

The manual only talks about $<int> and $idx

Re: variable $it not set - updating itn book

Posted: Tue Dec 06, 2011 7:15 pm
by Lutz
The example in the WikiBooks introduction should be changed to:

Code: Select all

(set 'wd "cream")
;-> "cream"
> (setf (wd 0) (char (inc (char (copy $it)))))
;; or: (setf (wd 0) (char (+ (char $it) 1)))
;-> "d"
wd
;-> "dream"
Without the copy you get a protection violation for $it which must not be changed.

The system variable $it is mentioned in the 10.3.3 doc for setf

http://www.newlisp.org/downloads/newlis ... .html#setf

look at the last examples.

$it is also used in several other functions. For an overview of system variables see here:

http://www.newlisp.org/downloads/newlis ... em_symbols

Re: variable $it not set - updating itn book

Posted: Tue Dec 06, 2011 8:13 pm
by Lutz
... turns out it should not give a protection error. char shouldn't pass out the reference to inc. This will be fixed.

ps: fixed for this week's development release 10.3.8 for char and other functions. A change in the WikiBook Introduction is not necessary.

Re: variable $it not set - updating itn book

Posted: Wed Dec 07, 2011 1:20 am
by conan
Lutz wrote: The system variable $it is mentioned in the 10.3.3 doc
http://www.newlisp.org/downloads/newlis ... em_symbols
Sorry about that Lutz, my bad. I just went for the index instead of searching and now I'm noticing that the index is for functions and that there're plenty of mentions of $it.
Lutz wrote: A change in the WikiBook Introduction is not necessary.
Should it mention the different behavior (pre and post v10.3.8) ?

Re: variable $it not set - updating itn book

Posted: Wed Dec 07, 2011 2:00 am
by Lutz
Perhaps we should then update the introduction with this:

Code: Select all

 (setf (wd 0) (char (+ (char $it) 1)))
and then it covers all versions.

Ps: just did the modification in WikiBooks.

Re: variable $it not set - updating itn book

Posted: Wed Dec 07, 2011 8:53 am
by cormullion
Cool to see some collaborative editing action, thanks guys. Btw, only registered users can make changes without a reviewer accepting them; I think this is because I marked the book's status as nearly completed... :) Which it never will be, I hope!