Timeline for Is the "callback" concept of programming existent in Bash?
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 25, 2024 at 4:04 | comment | added | slebetman | @EdSwangren To be safe I'd still qualify that as "almos no programming language". Almost because there are languages like Piet and Logo that has no way to execute or eval an external command/function (Piet is a language where you program by changing pixel colors in an image - can be bmp, or gif, or png as long as it can store a picture of pixels, Logo is a language where you give commands to a cursor (called the turtle) to move on screen and draw line on screen). I'm not entirely sure if Brainfuck or Whitespace can exec system commands. So there are technically languages that can't do it | |
| Jan 25, 2024 at 4:00 | comment | added | slebetman | @EdSwangren As stated in my comments. If you accept that definition then there's no programming language in the world that does not have the ability to pass a callback. Which makes a callback more of a design pattern, not a language feature - which is kind of my point. It is not specifically a feature that you need to ask "does this exist in language X" (the literal OP question) - it's more a matter of creativity - how creative are you at programming? | |
| Jan 24, 2024 at 13:16 | comment | added | Ed Swangren | I honestly don't even understand what the point is that you're trying to make anymore. | |
| Jan 24, 2024 at 13:15 | comment | added | Ed Swangren | well, in the world of digital microprocessors, you're just passing around umbers that point to more numbers that have semantics meaning to the cpu in question. so everything is really nothing I guess, or you're in the forest talking implementation details while what matters is the concept. It's even in the title of the question. Which implementations would you accept as meeting your secret criteria of what a function is? We can pass code to execute later. viola, a callback is born. this is boring. | |
| Jan 6, 2024 at 1:57 | comment | added | slebetman | @EdS. Well, in the bash examples above we're just passing strings. In that case yes, all languages allow you to pass strings and in almost all languages there is always a mechanism to execute a program by passing it's name/path as a string. I guess the only languages where this is impossible are non-text based languages such as Scratch or Piet or toy languages like Brainfuck. | |
| Jan 5, 2024 at 19:45 | comment | added | Ed Swangren | "or some less so that can still be passed around as an opaque thing" I'm aware. My point was that a callback is just a way to pass around a some code to be called at a later point. I think. I was probably drinking if I was here leaving comments. | |
| Dec 31, 2023 at 12:51 | comment | added | slebetman | @EdS. C/C++. There are no first class functions in C but operating systems like Linux (written in C) still heavily use callbacks in interrupt handlers. Different compilers handle it differently for example the Microchip C18 compiler uses the #pragma interrupt to mark a function as an interrupt. I've worked with code that uses function pointers in C stored in arrays. Those are callbacks in a language that doesn't support first-class functions. You can also look at the Qt GUI library and it's concept of slots. In OOP the Strategy Pattern is basically a callback system written manually | |
| Dec 31, 2023 at 10:20 | comment | added | Ed Swangren | "callbacks are rarely directly features of languages" - a callback being no different than a first class function or some less so that can still be passed around as an opaque thing, can you think of a language that doesn't feature them directly? | |
| Sep 26, 2018 at 11:59 | history | edited | slebetman | CC BY-SA 4.0 | deleted 59 characters in body |
| S Sep 26, 2018 at 11:59 | history | edited | user88036 | CC BY-SA 4.0 | added 10 characters in body |
| Sep 26, 2018 at 11:49 | review | Suggested edits | |||
| S Sep 26, 2018 at 11:59 | |||||
| Sep 23, 2018 at 17:24 | history | edited | slebetman | CC BY-SA 4.0 | added 14 characters in body |
| Sep 23, 2018 at 8:24 | history | edited | slebetman | CC BY-SA 4.0 | added 4 characters in body |
| Sep 23, 2018 at 8:22 | comment | added | slebetman | Other examples of programs/scripts that accept callbacks include watch and find (when used with -exec parameter) | |
| Sep 23, 2018 at 8:13 | history | answered | slebetman | CC BY-SA 4.0 |