4 ms·
I had just realized that prior to coming back here. The example given would evaluate. I could probably do the same with some operator overloading to emulate laz
by Sanddancer 11y ago
I had just realized that prior to coming back here. The example given would evaluate. I could probably do the same with some operator overloading to emulate lazy evaluation, but it would be a bit more complicated.
- dsp1234 11y agoI'm pretty sure the specification for C# disallows any instance where the arguments to a function are not evaluated at the time the function is called aka lazy evaluation. This, of course, is the whole point of the statement 'try doing this in your language' that the klisp website makes. In other words, it's not possible to create an 'and' function in C# (or JavaScript) that does not evaluate it's arguments before executing. You can certainly hard code that type of logic in your code (using && in both languages), but a generic function with a signature of and(a, b) is out of reach. As a specific example, imagine B is a function that evaluates to a list of all even whole numbers and A is always false. C#/JavaScript/etc will never complete, whereas klisp (and other languages with lazy evaluation) will have no problem returning false immediately.