But come on, it doesn't even have first-class functions. There are countless examples of unreadable macros and code duplication out there due to GLSL's extreme simplicity.
But come on, it doesn't even have first-class functions. There are countless examples of unreadable macros and code duplication out there due to GLSL's extreme simplicity.
A good example there is `twist-func' which takes in a world-space position, a block that hands back a twist factor, and a block that receives the transformed position (in object space). Once you start doing things that way, you end up with ridiculously rapid development, which is the whole reason I created this family of languages; started as an experiment to take APL/K, Lisp, and Forth and smash them all together, and it ended up working out well enough that I've kept it going for 7 years now.
https://www.iquilezles.org/www/articles/distfunctions/distfu...
If you scroll down to the section "Deformations and distortions", you'll notice that iq wishes so hard there were first class functions in GLSL that he pretends they exist in all the code examples (the deformation functions all take functions as parameters).
As for macros specifically filling in the role of first class functions, this is sometimes done by creating a macro that takes a function as parameter. So for example, iq's functions above could be turned into crazy macros.
Have a look at "4.2 Branching" in http://developer.amd.com/wordpress/media/2013/12/AMD_GCN3_In...
Also, it's possible to compile code using function pointers down to more limited forms of flow control instructions.