8 ms·
Suppose the langauge has a built-in printf() and sleep() function. You could say main=printf("Hello World"), which declares that your program is equivalent to
by gizmo686 11y ago
Suppose the langauge has a built-in printf() and sleep() function.
You could say main=printf("Hello World"), which declares that your program is equivalent to the action of printing "Hello World".
You could also say that main=sleep(1), which declares that your program is equivent to the program sleep(1).
You can also say that main=sleep(1) >> printf("Hello World"), which says that your program is equivent to the program that sleeps for a second, then prints "Hello World".
You can even create syntactic sugar around the concatenation operator, so it looks like you are programming in an imperative language.
If the concatenation operator happens to be over-loadable, you can do a lot of neat stuff with it. Even if it isn't, you can define common control flow operations (such as for loops) at the language level, which means that you can just as easily define new control flow operations that the language designers didn't think of.
- pekk 11y agoPrefixing "main=" to a subroutine definition is no different from any language's syntax for declaring subroutines. If that means every programming language is declarative, then declarative doesn't even mean anything.
- anon4 11y agoOkay, but why the weird syntax and not the standard C style int main() { sleep(1); printf("Hello World"); return 0; } And then you can say "pure functions can be evaluated in any order". Maybe impure functions can be suffixed by a !.