Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Self modifying turing program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ryan.s




PostPosted: Mon Jan 14, 2013 6:06 pm   Post subject: Self modifying turing program

Hi all,

Given that turing is an interpreted programming language, I was wondering if I could make a program that modifies its own source code during execution, and then acts on the new instruction.

The problem I am having is that turing seems to read and compile all the files before it executes any instructions, so if the program modifies itself (for example, modifies the return of one of its include files), the change isn't executed unless you exit the program and re launch it.

The reason I want to do this is because I am making an order of operations caculator in turing. I know the Turing interpreter can do order of operations for you (if you enter an equation in the source code, for example, it will solve it for you).

Instead of writing my own algorithm, I was hoping there would be some way to tap into this (basically, get the user to enter the equation, then when they press '=', write the equation to the return statement of a function in another file, call the function, get the anwser).

As I said before, the problem seems to lie in the fact that the include .t file is loaded before execution starts, even though the actual include / import statement is after the equation should be entered.

My question: is there anyway to either tell the interpreter to read the included file later, tell the interpreter to reload the file, or any other way to alter the source code and then re interpret it?

Thanks,
Ryan
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jan 14, 2013 7:51 pm   Post subject: Re: Self modifying turing program

ryan.s @ Mon Jan 14, 2013 6:06 pm wrote:
Given that turing is an interpreted programming language...

Turing is compiled.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ryan.s




PostPosted: Mon Jan 14, 2013 8:52 pm   Post subject: Re: Self modifying turing program

Oh, ok I wasn't aware that it can be considered a compiled language... in that case is there any way to force recompilation of a certain portion?
ryan.s




PostPosted: Mon Jan 14, 2013 9:05 pm   Post subject: RE:Self modifying turing program

imma guess that no, that changes things... man im surprised though, given how slow turing is I would have thought it surely was interpreted!
Insectoid




PostPosted: Mon Jan 14, 2013 10:20 pm   Post subject: RE:Self modifying turing program

Just because it's compiled does not mean it is compiled well. Some compiled languages are very slow, and some interpreted languages are blazing fast.

When you run your Turing program, look at the bottom of the code window. You'll see 'compiling...' as one of the steps taken before the program runs.
ryan.s




PostPosted: Mon Jan 14, 2013 10:33 pm   Post subject: RE:Self modifying turing program

Are you sure it is compiled? Mine usually just says "generating dependancy graph"

Also, according to DWITE, Turing is interpreted (it is run by hacker dan) As seen here:

http://dwite.org/judge
Tony




PostPosted: Mon Jan 14, 2013 11:31 pm   Post subject: RE:Self modifying turing program

Turing is "interpreted" the way Java is an interpreted language -- the implementation does not generate machine-level code (although Java comes with Just-In-Time compilers (JIT) that actually generate machine code).

Since Turing's bytecode is bundled with the runtime environment and all of the dependencies are resolved at the time of generation, for all practical purposes, it can be considered a compiled language.

As Insectoid points out, there's a set of interpreted languages that are faster than another set of compiled languages. You can't generalize about performance on that alone.

Ninja-edit: if you want to take a look at the Turing internals, there's https://github.com/Open-Turing-Project/OpenTuring
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ryan.s




PostPosted: Mon Jan 14, 2013 11:44 pm   Post subject: RE:Self modifying turing program

Thank you for your reply, I am actually interested in looking at the internals for turing (if I manage to make sense of them). Are the turing standard functions actually written in turing, or are they written in the language of the 'compiler' and then simply called as needed from the environment itself?

Also, I was wondering if there is a file that can be used to define the language in notepad++ (I think it wants an XML doc). I would prefer to use N++ for the actual programming and just run it through the turing ide, however I have yet to find a file that could easily import all the keywords and such

Thanks,
Ryan
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: