Skip to main content
10 events
when toggle format what by license comment
S May 28, 2022 at 16:29 history suggested Stanley Yu CC BY-SA 4.0
minor edits on grammar and wording
May 28, 2022 at 15:32 review Suggested edits
S May 28, 2022 at 16:29
Sep 25, 2018 at 14:29 review Suggested edits
Sep 25, 2018 at 15:08
Sep 21, 2018 at 12:05 comment added mikemaccana Glad to hear it. I disagree that people writing both the code that uses a callback and the callback isn't common or is an edge case, and, because of the confusion, that this answer conveys the basics.
Sep 21, 2018 at 11:49 comment added Gilles 'SO- stop being evil' @mikemaccana Of course it's possible that the same person wrote the two parts of the code. But it isn't the common case. I'm explaining the basics of a concept, not giving a formal definition. If you explain all the corner cases, it's difficult to convey the basics.
Sep 21, 2018 at 11:43 comment added mikemaccana 'A callback is when code that you write is called from code that you didn't write.' is simply wrong. You can write a thing that does some non-blocking async work, and run it with a callback it will run when completed. Nothing is related to who wrote the code,
Sep 21, 2018 at 11:01 history edited Gilles 'SO- stop being evil' CC BY-SA 4.0
added 11 characters in body
Sep 21, 2018 at 10:42 comment added IMSoP @JohnDoea I think the idea is that it's ultra-simplified in that it's not a function that you'd really write. But perhaps an even simpler example would be something with a hard-coded list to run the callback on: foreach_server() { declare callback="$1"; declare server; for server in 192.168.0.1 192.168.0.2 192.168.0.3; do "$callback" "$server"; done; } which you could run as foreach_server echo, foreach_server nslookup, etc. The declare callback="$1" is about as simple as it can get though: the callback has to be passed in somewhere, or it's not a callback.
Sep 21, 2018 at 9:03 comment added Chris Davies Particularly nicely explained
Sep 21, 2018 at 7:10 history answered Gilles 'SO- stop being evil' CC BY-SA 4.0