Hacker News new | past | comments | ask | show | jobs | submit login

Actually there are other problems that are caused by the fact that you're not really doing HOAS, but something even more difficult, namely trying to infer the function by passing in values.

For example

  LJSON.stringify(function(v) { if (v == 0) { return "zero"; } else { return "one"; } })
Evaluates to the string

  (function(v0){return "one"})
The only way to avoid both these issues, is to inspect the code of a function f using f.toString(). However you would need to consider the scope where f was defined.



Ah, fair enough. The user should avoid using native JS constructs on the code to be stringified, though - it is an interesting/useful side effect of the method that you are able to, but ideally you would define your functions using only the pure λ-calculus grammar.

Thanks for figuring that out!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: