newLISP Fan Club

Forum => newLISP in the real world => Topic started by: conan on December 06, 2011, 04:22:22 AM

Title: variable $it not set - updating itn book
Post by: conan on December 06, 2011, 04:22:22 AM
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?title=Introduction_to_newLISP/Strings&stable=0#Modifying_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
Title: Re: variable $it not set - updating itn book
Post by: Lutz on December 06, 2011, 11:15:15 AM
The example in the WikiBooks introduction should be changed to:


(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/newlisp_manual.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/newlisp_manual.html#system_symbols
Title: Re: variable $it not set - updating itn book
Post by: Lutz on December 06, 2011, 12:13:32 PM
... 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.
Title: Re: variable $it not set - updating itn book
Post by: conan on December 06, 2011, 05:20:40 PM
Quote from: "Lutz"
The system variable $it is mentioned in the 10.3.3 doc

http://www.newlisp.org/downloads/newlisp_manual.html#system_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.


Quote from: "Lutz"
A change in the WikiBook Introduction is not necessary.


Should it mention the different behavior (pre and post v10.3.8) ?
Title: Re: variable $it not set - updating itn book
Post by: Lutz on December 06, 2011, 06:00:37 PM
Perhaps we should then update the introduction with this:


(setf (wd 0) (char (+ (char $it) 1)))

and then it covers all versions.



Ps: just did the modification in WikiBooks.
Title: Re: variable $it not set - updating itn book
Post by: cormullion on December 07, 2011, 12:53:08 AM
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!