Programming language for self-modifying code?

后端 未结 14 1756
别那么骄傲
别那么骄傲 2020-12-23 13:05
  • I am recently thinking about writing self-modifying programs, I think it may be powerful and fun. So I am currently looking for a language that allows
14条回答
  •  北海茫月
    2020-12-23 13:44

    I highly recommend Lisp. Lisp data can be read and exec'd as code. Lisp code can be written out as data.

    It is considered one of the canonical self-modifiable languages.

    Example list(data):

    '(+ 1 2 3) 
    

    or, calling the data as code

    (eval '(+ 1 2 3)) 
    

    runs the + function.

    You can also go in and edit the members of the lists on the fly.

    edit:

    I wrote a program to dynamically generate a program and evaluate it on the fly, then report to me how it did compared to a baseline(div by 0 was the usual report, ha).

提交回复
热议问题