|
Hi Don - >Date: Wed, 8 Mar 2000 09:55:25 -0500 (EST) >From: Don <dr2@cssas400.com> >Subject: Re: How about in INC opcode ... >OK, it's been a while since I've studied compiler construction theory >here, but, since the interpretation process in effect parses and >translates the the command into some machine runnable instrucion(s), I >don't see the strength in the interpreted vs compiled line of thought >here...What am I not seeing? (caveat: I'm still only on cup 2 of coffee >this morning...:) The problem is not in a lack of understanding about compilers but a lack of understanding about interpreters. An interpreter is not a mini, on-the-fly compiler. It does *not* change the language instructions to machine instructions and then run them. It parses the command and then does what the commands says to do, no machine instruction generation is involved. (That's why porting an interpreter to another platform is so much easier than porting a compiler.) I'm not familiar with Perl, so I'll use interpreted BASIC as an example (I wrote a BASIC interpreter in RPG back on the S/34 or S/36 many years ago). Take a FOR/NEXT loop: FOR A=1 TO 20 do something NEXT A A BASIC interpreter does not build machine code for the loop. Instead, it goes to its variable table and looks for "A". If it doesn't find it, it creates an entry. Then it sets the value for of A to 1. Then it adds an entry to the loop control table for a loop based on "A" that points to the start of the A and has the ending limit and the increment value. Then it goes to the statement following the FOR command. When it hits the NEXT command, it takes that variable name and gets the value from the variable table. It finds the loop control record, adds the increment value to the variable and compares it to the ending limit. If the loop is done, it removes the loop control record and reads the statement following the NEXT statement. If the loop is not done, it uses the statement pointer from the loop control table to go up and read the statement following the FOR command. Ken Southern Wine and Spirits of Nevada, Inc. Opinions expressed are my own and do not necessarily represent the views of my employer or anyone in their right mind. +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.