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

Q&A's, tips, howto's
Locked
Fritz
Posts: 66
Joined: Sun Sep 27, 2009 12:08 am
Location: Russia

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

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

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

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

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

Fritz
Posts: 66
Joined: Sun Sep 27, 2009 12:08 am
Location: Russia

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

Post by Fritz »

Thank you!

Locked