by taeric · 3y ago · 0 comments
Seeing them make an odd resurgence in recent years has been awkward. I'm not entirely clear that they make things much more readable than alternatives. Reminds me of thinking continuations were amazing, when I saw some demos. Than I saw some attempts at using them in anger, and that rarely worked out that well.
Also to the point of the article, I love being "that guy" that points out that LISP having a very easy "code as data" path makes the concerns expressed over the "command" system basically go away. You can keep the code as, essentially:
(DriveForward 0.5 48)
(while (NotCarryingBall)
(Grab)
(pause 2))
(DriveBackward -0.5 48)
(Shoot)
With god knows how much bike shedding around how you want to write the loop there.Of course, you could go further for the "pretty" code that you want by using conditions/restarts such that you could have:
(DriveForward 0.5 48)
(Grab)
(DriveBackward -0.5 48)
(Shoot)
And then show what happens if "Grab" is unsuccessful and define a restart that is basically "sleep, then try again." Could start plugging in new restart ideas such as "turn a little, then try again." All without changing that core loop.You can /kind/ of do this with java, of course. Just make sure to not use "new FooCommand" and instead change the "foo" function to return a the command object. No reason that couldn't be done; but, and this is the big difference, it requires building a ton of scaffolding in the java program to support both ideas at the same time. In lisp, it is fairly easy to wrap in a macro. Still somewhat magical, I suppose, but no more so than the rest of the compilation/build process.
That make sense? I'm somewhat interested in this, so more than happy to try and do a blog post on the idea, if that would help.