65 karma · joined October 10, 2024
Good call! I got rid of all numbers above 2, I can't count that high anyway ;-)
I'm not sure if I would characterize Brainfuck as a stack language, but I suppose if you considered all the operators to be unary stack operations I could see it!
And yup, the order of evaluation is leftmost innermost.
``\\0`,.`,.
with stdin "hi" will print "hi". call/cc& = \f. \k. f k k
Then in f you can invoke the continuation k as many times as you want, but that does involve a whole program transformation to CPS.Agreed on having too many characters though, I don't like that having numerical indices makes the syntax whitespace-sensitive, too.
And once I figure out how to write hello world, those character literals are gone!
putchar I feel kind of weird about, it acting as an identity function with a side effect is kind of weird; I'm not sure changing it to take a second argument as a continuation would make it better or worse.
Regarding the de Bruijn indices, I don't think there's a huge distinction between writing 3 vs writing ---: it would still form a single lexical token, so I feel like --- is just more noise.
Perhaps a de Bruijn index register you could move around and dereference? e.g. from index 1, index 3 is >>*, then index 2 from there is <*. But that feels less functional, because you're now imperatively manipulating some hidden state.
``\\1`.'h``\\1`.'e``\\1`.'l``\\1`.'l``\\1`.'o``\\1`.' ``\\1`.'w``\\1`.'o``\\1`.'r``\\1`.'l``\\1`.'d`.'!