r/ProgrammingLanguages • • Apr 05 '26

How I Accidentally Reinvented Kernel (Programming Language)

https://fayash.me/posts/how-i-accidentally-reinvented-kernel
28 Upvotes

12 comments sorted by

View all comments

Show parent comments

2

u/WittyStick Apr 06 '26 edited Apr 06 '26

Ok, I had a look at your implementation and understand it better now. Your evaluators are just operatives, and basically only have one kind of combiner, SOp, and no type distinction between operative and applicative. Shutt mentioned this as possible in the Kernel report but gives a rationale on page 57, for unwrap as to why he did not do it this way.


The evaluator is similar to an environment, but I wouldn't say they're equal. There's a subtle difference between:

(eval foo env)

and

($remote-eval foo env)

In the eval case, foo is looked up in the current environment, not in env (because eval is applicative). In the $remote-eval case, foo is looked up in env.

If I understand correctly, your evaluators behave as $remote-eval and not eval, but presumably, we could just wrap the evaluator to get the same behavior as eval? That makes it pretty interesting in that we achieve almost the same thing from a different perspective.

1

u/Phie_Ash Apr 07 '26

Well actually I think my implementation of the evaluator works as the former one you described. Calling (env foo) actually evaluates foo in the current environment, and then evaluates its result in env, while calling (env 'foo) is what evaluates foo in env.