Failing to make scheme interpreter

I wanted to make a scheme interpreter,but then quickly found out that there were too much syntactic sugar/salt.
Luckily we are on Snap which doesn't need that much syntactic sugar/salt
(i only know the list block which is a sugar that removes the need of consing)

Someone tell me how to make it?

(i am working on a version without syntactic sugar/salt,i.e only cons for you :imp: :slight_smile: )

ps:(unrelated)is there a representation of booleans where they are while loops?just like church numerals are for loops/repeat x times

ps:(unrelated,i dont want to spam the forum with topics)
Snap vs C++

i don't think a while loop makes sense, because true would just repeat forever. while loops take a predicate, generally not just a boolean.

it would almost certianly be better represented with IF, which happens to be the same as the church numerals 0 and 1 (that's a guess based on your comment, i can't be bothered to actually check what church numerals are exactly)

Yes.True will repeat another time and False will jump out

0=False,1!=True

my point is that it would get stuck and nothing useful could be done after that, unless you put all the logic in it. there's no benefit to having it run more than once.
either that, or your description isn't accurate

why not?

bc it is what church said

yeah maybe
anyways im a bit offtopic

C'mon, you know how to ask a question. What are you stuck on?

About syntax, just start with the Scheme code as a list


True is 位t . 位f . t
False is 位t . 位f . f

...where they are while loops?

" :frowning: " inducing parser
i mean that the syntax has too much suger in it and i dont want to parse this much possiblilities of an expression

Yeah (i have already made it and the topic is on my drafts list)
I actually have already made the (half-hearted) parser,and if you just call "gobble leftovers" it would do what you are expecting.(although slightly different,the parameters should be in one list so its like this


yeah cumbersome,but thats the reason i have a parser

actually i found a bug on parsing >1 params when making this pic loool
now i fixed it
)

bh you can go to my project now Snap! Build Your Own Blocks

I don't understand this... oh wait, do you mean how do you make a predicate? Because your point about while loops is that the predicate has to be invoked each time through the loop? I don't think there is a WHILE primitive in Scheme, but if there is one, and if it's a special form, then you have to wrap a lambda around the predicate expression. In Scheme it's just (lambda () ...). If you wanted to do it in true lambda calculus where every function has exactly one input, you'd generate a variable that's not used in the body.

What do you mean? The parentheses tell you what goes with what, unambiguously, no special cases. That's why I suggested just starting with the lists already created, then come back to the listification (the reader, as we say in lispland) after everything else is done.

The core of an evaluator consists of two procedures, EVAL and APPLY. This is what Chapter 4 is about, but here's a simple version:

(define (apply function args)
  (if (primitive? function)
      (call-in-underlying-language function args)
      (eval (lambda-body function)
            (extend-environment
              (lambda-env function) ;; lexical scope
              (make-frame
                (lambda-parameters function)
                args)))))

(define (eval exp env)
  (cond ((self-evaluating? exp) ;; numbers, t/f
         exp)
        ((symbol? exp)
         (lookup-in-env exp env))
        ((lambda-exp? exp)
         (eval-lambda exp env))
        ((if-exp? exp)
         (eval-if exp env))
        ; ... more special forms ...
        (else (apply (eval (car exp) env))
                     (map (lambda (exp) (eval exp env))
                          (cdr exp))))))

and then you just write all the special forms, eval-lambda and so on.

aww i was meaning lambida stuff
maybe i shouldnt offtopic

Are you trying to make an self interpreter?
Anyways,if you hasn't seen it,i had made a working one but without builtin functions(with apply,lambda,and var tho)Snap! Build Your Own Blocks

I'm confused. The name of this thread is "Failing to make scheme interpreter." Are we now talking about something else?

Anyways,you can look at my parser project(maybe i should change the topic name to succeeding in making a scheme interpreter

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.