Re:Turns out GCC has imperative argument handling
by rayiner on Friday July 01, 2022 @06:42PM
(#31953945)
Pedant: That’s not imperative. You can have a purely functional program that uses a flag in a list to treat subsequent arguments in a list differently. Just have a conditional on the flag, and recursively call “do_things_this_way” on one branch and “do_things_that_way” on the other.
[ Parent
| on HN ]
Re:Turns out GCC has imperative argument handling
by LegionMammal978 on Friday July 01, 2022 @08:14PM
(#31954692)
I think the comparison here is imperative (i.e., stateful and sequential) vs. declarative (i.e., stateless), not declarative vs. functional.
Re:Turns out GCC has imperative argument handling
by xg15 on Saturday July 02, 2022 @08:35AM
(#31958507)
I think there is no clear boundary where "order dependant" ends and "imperative" begins, but it's at least pretty unusual to use the same flag - or even mutually excluding flags! - together multiple times in the same invocation.
I think as a rule of thumb, if you have to mentally keep track of some internal data structure to make sense of your invocation, you're usually pretty deep in "imperative" territory.
> and recursively call “do_things_this_way” on one branch and “do_things_that_way” on the other.
That's the usual algorithm by which imperative logic is translated into equivalent functional logic though.
We know for about as long as computers exit that the two are equivalent in terms of computational power - in the sense that any imperative program can be translated into a functional program that does the same thing and vice versa. That doesn't mean the two programs are identical though.
Re:Turns out GCC has imperative argument handling
by skissane on Friday July 01, 2022 @07:14PM
(#31954269)
Pedant: You can have a purely functional program which is an interpreter for BASIC or COBOL or FORTRAN (at least for batch/non-interactive programs, although it may depend on exactly what you mean by “pure”.) Does that mean, since those languages can be correctly interpreted by a purely functional program, that they aren’t “imperative”?