Page 1 of 1

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

Posted: Tue Jun 29, 2010 1:52 pm
by Fritz
I`m used to join "find-all" and "replace" operators via $it/$0 symbol:

Code: Select all

(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?

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

Posted: Tue Jun 29, 2010 2:54 pm
by Lutz
This is a bug introduced in 10.1.12 (*). As a workaround define a function for the change operation:

Code: Select all

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:

Code: Select all

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

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

Posted: Tue Jun 29, 2010 3:16 pm
by Fritz
Thank you!