ADVANCED COMPOSITING & RETOUCHING - Chapter 6, Exercise 2 Understanding Prefix Notation in (gimp-image-flatten image) ==================================================================================== QUESTION: Explain what (gimp-image-flatten image) means in terms of ordinary function-call syntax, and why this notation style is called "prefix notation." SOLUTION / EXPLANATION: In many mainstream languages, calling a function on an object is usually written with the function name coming AFTER (or attached to) the object it operates on - for example, something like image.flatten() in a dot-notation, object-oriented style, where "image" comes first and the operation "flatten" follows it. Scheme (and Script-Fu, since it's built on Scheme) does the opposite: the function name comes FIRST, immediately inside the opening parenthesis, followed by whatever arguments it takes. So: (gimp-image-flatten image) reads as: "call the function named gimp-image-flatten, passing image as its single argument." The function name (gimp-image-flatten) is written before its argument (image), both wrapped together in one set of parentheses. This is exactly equivalent in meaning to the dot-notation image.flatten() from other languages - it flattens the given image - but the ORDER the function name and its argument appear in is reversed, and everything is wrapped in parentheses rather than using a dot or a separate pair of call-parentheses after the function name. This is called "prefix notation" (also known as Polish notation) precisely because the operator or function name is always placed BEFORE (as a "prefix" to) its arguments, rather than after them or between them. This is consistent throughout all of Scheme, not just for GIMP-specific functions - even ordinary arithmetic is written this way, e.g. (+ 2 3) means "add 2 and 3," with the + operator itself written first, before the numbers it operates on. -------------------------------------------------------------------------- WHY THIS WORKS AS AN ANSWER: It translates the specific example into an equivalent, more familiar dot-notation phrasing so the meaning is clear, then explains precisely why the term "prefix notation" applies (the function name always precedes its arguments), and generalizes the pattern beyond just this one GIMP-specific example to show it's a consistent language-wide rule, not a one-off quirk.