On Apr 12, 5:06=A0am, b...@[EMAIL PROTECTED]
(Brian Harvey) wrote:
> alexmcn...@[EMAIL PROTECTED]
writes:
> >off to study CS at degree level in September... (I probably shouldn't
> >be writing an interpreter at this age, its just one of those things
> >i've allways wanted to do [...]
>
> There's no "should" about it -- the worst that'll happen is that it
won't
> be a perfect interpreter! :-)
>
> >I just don't know whether I have the time to wait for the ****pping
> >from the US.
>
> Sigh, okay, look in
> =A0 =A0 =A0 =A0http://www.cs.berkeley.edu/~bh/logoworks
> and you'll find 21 jpegs of the relevant pages. =A0They're not perfect,
si=
nce
> the book isn't bound in a way that allows for laying it flat on the
scanne=
r,
> but it'll do. =A0(Also, if I were more computer literate I'd have
figured =
out
> how to eliminate all the greyscale stuff so the files would be smaller!)
>
> > The one problem I have with your
> >suggestion is that, it would mean essentially programming a lisp or
> >list orientated language... Is this needed for LOGO? I know it is
> >essentially LISP based but I was hoping just to store multiple repeats
> >in the same array string and just evaluate by first going to the
> >middle repeat E.g. REPEAT 30 [ REPEAT 20 [ REPEAT 10 [ ] ] ] and
> >working backwards <<< (outwards) until I got to the last REPEAT...
>
> You can implement lists in pretty much any language that lets you
manipula=
te
> pointers. =A0But I agree that VB isn't my implementation language of
choic=
e.
> It'd be much easier if you did it in Lisp! =A0That way you could focus
you=
r
> attention on the interesting parts instead of having to invent basic
data
> structures.
>
> Why are you so focused on REPEAT as a special case? =A0For one thing, IF
a=
nd
> IFELSE and TEST and RUN all use the same kind of instruction list input
as=
> REPEAT. =A0But, more im****tantly, even without any of those, when you
say
>
> =A0 =A0 =A0 =A0 forward sum 20 30
>
> the EVAL of that instruction requires an EVAL of the subexpression
>
> =A0 =A0 =A0 =A0 sum 20 30
>
> If you use infix arithmetic, it's just that much harder to find the
right
> subexpression to evaluate next.
>
> >Anyway, Thanks for your help so far... One final point, If I won't be
> >able to get that book, is there a chance I could find something
> >similar that could teach me the basics? (preferably available for free
> >in electronic form)
>
> It depends what you mean by "basics." =A0What you /really/ should read
is =
the
> best computer science book ever written, _Structure and Interpretation
of
> Computer Programs_ by Abelson and Sussman and Sussman, which will teach
yo=
u
> the hidden mysteries of interpreters. =A0But it's not an easy read.
=A0But=
it
> /is/ available free online:
>
> =A0 =A0 =A0 =A0http://mitpress.mit.edu/sicp/full-text/book/book.html
>
> P.S. =A0Be sure to come to the Eurologo conference next summer (2009) in
P=
aris!
Hi Brian,
First of all, thanks for uploading the pages of the book, they have
given me a whole different insign into how a "real" interpreter works
(I was basically just going of guesswork)... I realise now each
function (e.g. FD) needs a set amount of inputs defined for it, so
when I have time I'm going to re-implement the interpreter using this
method.
The one problem I still have is the idea of control loops though, my
specific problem is still the same, if I have a statement such as the
one below:
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"?
Also when the full procedure has executed, how does the interpreter
know to go forward and not get in an endless loop of looking for the
"repeat"?
I hope that makes sense... I'm not sure if a nested loop like this
would be possible in VB... And yeah I think I am a little bit obsessed
with the REPEAT statement, I think I just don't get how you you can
iterate through a loop and then jump back to the previous position in
the sense of a interpreter.
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)
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...
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.


|