That said, InDesign contains a smalllish ("poor man's", heh heh) implementation of an XSLT processor, and XSLT is a proper example of FP. However, its implementation is messy (I find it's prone to crashing, and refusing even the simplest of stylesheets and/or XML documents, so I avoid it and use an external XSLT processor), and it lacks integration with the main engine of InDesign, so all you can do is move some text around.
Perhaps you can consider ScriptUI as some sort of Functional Programming, because this handles objects and message events.
(I'm wondering if the investment would be worth the result)
2 people found this helpful
2) Most of the things that make FP possible in JS are missing in ExtendScript (Array.map, Array.filter etc). Tail-end recursivity is also a no-no and even normal recursivity is iffy because memory leaks.
3) Some of the missing properties can be extended can be appended via polyfills etc, but ExtendScript is stuck in the year 2000, so it is missing things like Object.create and property attributes, some polyfills will fail or give strange results.
4) InDesign's DOM is nat very well suited for FP because almost every access to it has side effects.
All this being said, with a bit of work and preparation you can use FP, or at least FP-like coding (side effects being unavoidable in InDesign scripting). I do it whenever I can and it makes sense.
Thanks. This what what I was looking for;
Like everyone I wish Adobe would update ExtendScript...
I've Polyfilled map and filter so far -- and run into the object.create issue with a few of the prototypes. Memory leaks are a problem I've run into as well.
I'm going to keep experimenting -- like you said, it makes sense. (My original goal was to minimize the side effects but the other benefits of FP can come in useful, within the limits of the DOM)
And thanks for the link -- downloading now. Looks like it might be very useful