Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My prolog is certainly rough, but am I correct in thinking that this doesn't do closures? Or is there some aspect of the state-passing that I am missing?


I don't have Prolog on this computer, but it looks like the interpreter environment (state) is passed around in two a-lists.

Prolog can do neat tricks (difference lists!) with infinite data structures by passing around unbound variables, and then "retroactively" binding them, perhaps partially, further in the execution. It's conceptually different from lazy evaluation (more like dataflow variables), but has many similar applications. I wouldn't be surprised if it does handle closures automatically during unification of the code tree, though I can't check at the moment.

Prolog works by filling in all the blanks in a way that makes sense as a whole, but in this case it happens that the check if something could have been passed in as an argument can be used to set the argument to it, if valid. This probably sounds like weird quantum physics stuff, but Prolog is capable of testing whether the variables in the goal being tested are bound, explicitly binding and revoking them, collecting the list of possible valid bindings, etc.


Prolog is awesome and a totally different to think about programming. It makes my head hurt. Which means I should probably use it more.




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

Search: