variable $it not set - updating itn book

Q&A's, tips, howto's
Locked
conan
Posts: 52
Joined: Sat Oct 22, 2011 12:14 pm

variable $it not set - updating itn book

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: variable $it not set - updating itn book

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: variable $it not set - updating itn book

Post 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.

conan
Posts: 52
Joined: Sat Oct 22, 2011 12:14 pm

Re: variable $it not set - updating itn book

Post 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) ?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: variable $it not set - updating itn book

Post 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.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: variable $it not set - updating itn book

Post 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!

Locked