$0, $it, "symbol is protected" and find-all

Started by Fritz, June 29, 2010, 06:52:02 AM

Previous topic - Next topic

Fritz

I`m used to join "find-all" and "replace" operators via $it/$0 symbol:


(find-all "12" "12345" (replace "1" (copy $0) "N"))

But now, after upgrading to 10.2.8, newLISP says:



"ERR: symbol is protected : $0"



Is here a way to make this construction to work, or I`ll have to change my code somehow to avoid $0/$it symbols?

Lutz

#1
This is a bug introduced in 10.1.12 (*). As a workaround define a function for the change operation:


newLISP v.10.2.8 on OSX IPv4 UTF-8, execute 'newlisp -h' for more info.

> (define (change x) (replace "1" x "N"))
(lambda (x) (replace "1" x "N"))
> (find-all "12" "12345" (change $0))
("N2")


you could also use an anonymous function:


> (find-all "12" "12345" ((lambda (x) (replace "1" x "N")) $0))
("N2")


(*) fixed in development 10.2.10 to be released this week, this affects the 'copy' function, which still works copying, but falsely passes on a the protection status of the copied variable.

Fritz

#2
Thank you!