[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - (define ...) inside a default value
Page 1 of 1

(define ...) inside a default value

PostPosted: Fri Jul 25, 2014 4:31 am
by Zabolekar

Re: (define ...) inside a default value

PostPosted: Fri Jul 25, 2014 1:21 pm
by Lutz
It does literally what you tell it to do. newLISP is a fully self reflective language which can introspect or modify itself at run-time. In your example the function f is redefining itself while executing. The old discarded definition is collected by memory management and execution runs into invalid memory causing unexpected results or crashing.

When functions modify themselves, care must be taken to not replace code parts executing at the same moment.

See about self-modifying code in newLISP on this page: http://www.newlisp.org/index.cgi?Closures the paragraphs Introspection and Stateful functions using in-place modification.

Re: (define ...) inside a default value

PostPosted: Fri Jul 25, 2014 2:03 pm
by Zabolekar

Re: (define ...) inside a default value

PostPosted: Sat Jul 26, 2014 1:44 pm
by Lutz
Some functions in newLISP delay memory cleanup, but not applicable in this case.

Re: (define ...) inside a default value

PostPosted: Sat Jul 26, 2014 5:54 pm
by Zabolekar
Thanks.