Re: [racket-users] Self evaluating Racket Interpreter

2017-05-02 Thread Matthias Felleisen

> On May 2, 2017, at 12:01 AM, circularba...@gmail.com wrote:
> 
> I am somewhat reluctant to use structures as I want to keep the interpreter 
> as minimal as possible. Also, I'm not familiar enough with the semantics of 
> frames to implement it in interpreter.rkt.
> 
> With regards to mcons being different from cons, Oscar Lopez has suggested 
> that in stackoverflow. So, I re-implemented the interpreter in r5rs so that 
> set-car! and set-cdr! are available and I wouldn't need to use mcons. I've 
> attached the files here.
> 
> I still got an error
>; application: not a procedure;
>;  expected a procedure that can be applied to arguments
>;   given: (mcons 'expr (mcons 'env))
>;   arguments...: [none]
> 
> It looks like it still has something to do with mcons.


Not at all. I could just gibe you the answer (and tell you the fix, code 
unseen) but that would mean I don’t teach you how to fish, which is really what 
you need to learn. In this spirit, 


PLEASE READ THE ERROR MESSAGE. [caps intentional to draw attention] 

If you can’t figure it out from there, can you please help us improve it? 
Thanks. 







> I suspect that this might have something to do with Racket's implementation 
> of r5rs? Again, this might be completely wrong but I don't know how to 
> determine the cause. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread circularballs
On Tuesday, May 2, 2017 at 2:03:23 AM UTC+8, Jens Axel Søgaard wrote:
> I recommend you change your representation to structures.
> 
> 
> See new answer:
> 
> 
> http://stackoverflow.com/a/43723966/23567
> 
> 
> 
> /Jens Axel
> 
> 
> 
> 
> 
> 
> 2017-05-01 19:03 GMT+02:00  :
> I posted this question on stackoverflow but have not found an answer yet. 
> https://stackoverflow.com/questions/43476080/self-evaluting-racket-interpreter
> 
> 
> 
> I've been trying to write a Racket interpreter that can interpret itself.
> 
> 
> 
> interpreter.rkt contains the code for the interpreter. It is pretty standard. 
> Then, in interpreter-self-evaluate.rkt, I
> 
>     1. import interpreter.rkt,
> 
>     2. copy paste the code from interpreter.rkt and
> 
>     3. evaluate the code using the eeval function defined in interpreter.rkt.
> 
> 
> 
> However, this returns an error "; mcdr: contract violation". I suspect that 
> the problem is in interpreter-self-evaluate.rkt and that it might have 
> something to do with how quote works. I might be completely off base though. 
> Any ideas?
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> 
> 
> -- 
> 
> -- 
> Jens Axel Søgaard

I am somewhat reluctant to use structures as I want to keep the interpreter as 
minimal as possible. Also, I'm not familiar enough with the semantics of frames 
to implement it in interpreter.rkt.

With regards to mcons being different from cons, Oscar Lopez has suggested that 
in stackoverflow. So, I re-implemented the interpreter in r5rs so that set-car! 
and set-cdr! are available and I wouldn't need to use mcons. I've attached the 
files here.

I still got an error
; application: not a procedure;
;  expected a procedure that can be applied to arguments
;   given: (mcons 'expr (mcons 'env))
;   arguments...: [none]

It looks like it still has something to do with mcons. I suspect that this 
might have something to do with Racket's implementation of r5rs? Again, this 
might be completely wrong but I don't know how to determine the cause.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


interpreter-r5rs.rkt
Description: Binary data


interpreter-r5rs-self-evaluate.rkt
Description: Binary data


Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread Scott Moore
Matthias helpfully pointed me at this 
http://www.ccs.neu.edu/home/matthias/HtDP2e/part_two.html#%28part._i2-3%29, 
which made me reflect a bit more and I agree now it is fair to say that `(1 2 
3) is short for (list 1 2 3). Perhaps a reflexive reaction from letting myself 
get confused about quotation once too many times. ;)

On May 1, 2017, 2:04 PM -0400, Scott Moore , wrote:
> Hijacking this thread a little, but a pet peeve: ‘(1 2 3) is not short for 
> (list 1 2 3), it just happens to evaluate to that…
>
> (let ([x 0]) (list x x)) -> (list 0 0)
> (let ([x 0]) ‘(x x)) -> (list ‘x ‘x)
>
> Perhaps the reader should implement #l(, which inserts an explicit `list` at 
> the beginning of the list.
> Then there would still be a short way to write (list 1 2 3): #l(1 2 3), 
> without all the hiccups involved when using ‘ as an abbreviation for list...
>
> On May 1, 2017, 1:08 PM -0400, Ben Greenman , 
> wrote:
> > '(1 2 3) is short for (list 1 2 3)
> > which is short for (cons 1 (cons 2 (cons 3 null))
> > which is different from (mcons 1 (mcons 2 (mcons 3 null)))
> >
> > I hope this helps
> >
> >
> > > On Mon, May 1, 2017 at 1:03 PM,  wrote:
> > > > I posted this question on stackoverflow but have not found an answer 
> > > > yet. 
> > > > https://stackoverflow.com/questions/43476080/self-evaluting-racket-interpreter
> > > >
> > > > I've been trying to write a Racket interpreter that can interpret 
> > > > itself.
> > > >
> > > > interpreter.rkt contains the code for the interpreter. It is pretty 
> > > > standard. Then, in interpreter-self-evaluate.rkt, I
> > > >     1. import interpreter.rkt,
> > > >     2. copy paste the code from interpreter.rkt and
> > > >     3. evaluate the code using the eeval function defined in 
> > > > interpreter.rkt.
> > > >
> > > > However, this returns an error "; mcdr: contract violation". I suspect 
> > > > that the problem is in interpreter-self-evaluate.rkt and that it might 
> > > > have something to do with how quote works. I might be completely off 
> > > > base though. Any ideas?
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Racket Users" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send 
> > > > an email to racket-users+unsubscr...@googlegroups.com.
> > > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread Scott Moore
Hijacking this thread a little, but a pet peeve: ‘(1 2 3) is not short for 
(list 1 2 3), it just happens to evaluate to that…

(let ([x 0]) (list x x)) -> (list 0 0)
(let ([x 0]) ‘(x x)) -> (list ‘x ‘x)

Perhaps the reader should implement #l(, which inserts an explicit `list` at 
the beginning of the list.
Then there would still be a short way to write (list 1 2 3): #l(1 2 3), without 
all the hiccups involved when using ‘ as an abbreviation for list...

On May 1, 2017, 1:08 PM -0400, Ben Greenman , 
wrote:
> '(1 2 3) is short for (list 1 2 3)
> which is short for (cons 1 (cons 2 (cons 3 null))
> which is different from (mcons 1 (mcons 2 (mcons 3 null)))
>
> I hope this helps
>
>
> > On Mon, May 1, 2017 at 1:03 PM,  wrote:
> > > I posted this question on stackoverflow but have not found an answer yet. 
> > > https://stackoverflow.com/questions/43476080/self-evaluting-racket-interpreter
> > >
> > > I've been trying to write a Racket interpreter that can interpret itself.
> > >
> > > interpreter.rkt contains the code for the interpreter. It is pretty 
> > > standard. Then, in interpreter-self-evaluate.rkt, I
> > >     1. import interpreter.rkt,
> > >     2. copy paste the code from interpreter.rkt and
> > >     3. evaluate the code using the eeval function defined in 
> > > interpreter.rkt.
> > >
> > > However, this returns an error "; mcdr: contract violation". I suspect 
> > > that the problem is in interpreter-self-evaluate.rkt and that it might 
> > > have something to do with how quote works. I might be completely off base 
> > > though. Any ideas?
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to racket-users+unsubscr...@googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread Jens Axel Søgaard
I recommend you change your representation to structures.

See new answer:

http://stackoverflow.com/a/43723966/23567

/Jens Axel



2017-05-01 19:03 GMT+02:00 :

> I posted this question on stackoverflow but have not found an answer yet.
> https://stackoverflow.com/questions/43476080/self-
> evaluting-racket-interpreter
>
> I've been trying to write a Racket interpreter that can interpret itself.
>
> interpreter.rkt contains the code for the interpreter. It is pretty
> standard. Then, in interpreter-self-evaluate.rkt, I
> 1. import interpreter.rkt,
> 2. copy paste the code from interpreter.rkt and
> 3. evaluate the code using the eeval function defined in
> interpreter.rkt.
>
> However, this returns an error "; mcdr: contract violation". I suspect
> that the problem is in interpreter-self-evaluate.rkt and that it might have
> something to do with how quote works. I might be completely off base
> though. Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread Ben Greenman
'(1 2 3) is short for (list 1 2 3)
which is short for (cons 1 (cons 2 (cons 3 null))
which is different from (mcons 1 (mcons 2 (mcons 3 null)))

I hope this helps


On Mon, May 1, 2017 at 1:03 PM,  wrote:

> I posted this question on stackoverflow but have not found an answer yet.
> https://stackoverflow.com/questions/43476080/self-
> evaluting-racket-interpreter
>
> I've been trying to write a Racket interpreter that can interpret itself.
>
> interpreter.rkt contains the code for the interpreter. It is pretty
> standard. Then, in interpreter-self-evaluate.rkt, I
> 1. import interpreter.rkt,
> 2. copy paste the code from interpreter.rkt and
> 3. evaluate the code using the eeval function defined in
> interpreter.rkt.
>
> However, this returns an error "; mcdr: contract violation". I suspect
> that the problem is in interpreter-self-evaluate.rkt and that it might have
> something to do with how quote works. I might be completely off base
> though. Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.