Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • I regard "self modifying code" as quite different from "compile and execute new code". Could EVAL be used to change code that was part of the executing program (as opposed to changing the program text on disk, so that the change had to wait for the next reload of the program)? Even CHAINing to the new code doesn't seem like it's really self-modifying. Commented Jun 8, 2019 at 15:21
  • @another-dave obviously it's BASIC, so it's never compiled, but pedantry aside: EVAL evaluates a string from directly in memory and does whatever the interpreter would do if a user had typed it interactively. Very much like Javascript's eval(). The disk isn't involved; the *SPOOL/*EXEC suggestion (which, technically, isn't part of the BASIC but rather the OS underneath) was a separate suggestion, flowing from Michael Tracy's observations of HP BASIC. Commented Jun 8, 2019 at 17:43
  • 5
    @Tommy The original DTSS BASIC was compiled, and many PC implementations compiled to byte code. Commented Jun 8, 2019 at 19:40
  • 5
    Can one EVAL a string with a line number to change the currently running program? Commented Jun 10, 2019 at 19:39
  • 1
    According to bbcbasic.co.uk/bbcbasic/manual/bbckey2.html (which is for a newer variant of BBC basic but I doubt they would have removed features) It looks like EVAL only works with expressions not statements. Commented Jul 24, 2021 at 5:24