Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Logo > Re: New Logo In...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 1579 of 1596
Post > Topic >>

Re: New Logo Interpreter [Help Required]

by bh@[EMAIL PROTECTED] (Brian Harvey) Apr 16, 2008 at 02:20 PM

alexmcneil@[EMAIL PROTECTED]
 writes:
>     repeat 360 [ repeat 4[fd 50 rt 90] rt 1 ]
>
>I can understand how the interpreter understands the first section, it
>gets the command "repeat", gets its input (360) and starts repeating
>the functions inside, on the first iteration of this it sees the new
>repeat, gets its input (4) and repeats the code inside that loop...
>But how does it then know to return to the previous loop and more
>im****tantly, when it returns to the previous loop start at the end to
>execute "rt 1"?

REPEAT takes /two/ inputs, not one: a number and a list.  Its job is to
call EVAL, repeatedly, with repeat's second input as eval's input.

If there's another REPEAT inside the first one, then it's like any
recursive
invocation -- each invocation has its own local variables, including in
this
case the number of repetitions left.

You're imagining one invocation of EVAL scanning back and forth through
the
text, but that's not what happens; the text is scanned only once, and all
the stuff in brackets is just data (as always when things are in
brackets!)
given to REPEAT as its input.  The situation is sort of like what happens
when you call a user-defined procedure: the procedure's body is used as
input
to another EVAL call.

>Sorry if I seem like I am repeating myself... I did read your previous
>post thoroughly and understand that the evaluation needs to be more
>dynamic and less static, as in what if I had "sum 20 30 40 50 60"...
>in my current interpreter it just looks for two values, when really it
>needs to look for N values until a new command is found (In the new
>version I will make a list of all current commands that will be
>iterated through for that purpose) (recursion would also need to be
>used to get all inputs)

No, for

	print sum 20 30 40 50 60

what you get is

	50
	You don't say what to do with 40

It's if you say

	print (sum 20 30 40 50 60)

that you have to collect more inputs.  Every procedure has a minimum, a
default, and a maximum number of inputs.  For most procedures the three
values are equal, but for SUM they're 0, 2, and infinity.

>Also thankyou for the link to the computer science book, looks really
>interesting... If a little advanced... I can't wait to do the
>interpreter and compilers module @[EMAIL PROTECTED]
 University...

Unless you're really lucky, they won't give you SICP as a textbook, so you
should read it on your own!

>Also do you have some more details about the EuroLOGO Conference, What
>is it? I did a google search but I couldn't find anything about a
>conference in 2009... Maybe i'm a little early though.

Yes, it's early for 2009.  Look up Eurologo 2007 in Bratislava and you'll
get the idea of what Eurologo is like.
 




 9 Posts in Topic:
New Logo Interpreter [Help Required]
alexmcneil@[EMAIL PROTECT  2008-04-10 12:56:33 
Re: New Logo Interpreter [Help Required]
alexmcneil@[EMAIL PROTECT  2008-04-10 12:59:16 
Re: New Logo Interpreter [Help Required]
bh@[EMAIL PROTECTED] (Br  2008-04-11 04:22:48 
Re: New Logo Interpreter [Help Required]
alexmcneil@[EMAIL PROTECT  2008-04-11 10:42:32 
Re: New Logo Interpreter [Help Required]
bh@[EMAIL PROTECTED] (Br  2008-04-12 04:06:53 
Re: New Logo Interpreter [Help Required]
alexmcneil@[EMAIL PROTECT  2008-04-16 06:20:18 
Re: New Logo Interpreter [Help Required]
bh@[EMAIL PROTECTED] (Br  2008-04-16 14:20:13 
Re: New Logo Interpreter [Help Required]
alexmcneil@[EMAIL PROTECT  2008-04-19 02:31:40 
Re: New Logo Interpreter [Help Required]
bh@[EMAIL PROTECTED] (Br  2008-04-19 15:57:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 17:54:41 CDT 2008.