当前位置:网站首页>What is a callback function? Understanding of the word "back"
What is a callback function? Understanding of the word "back"
2022-07-26 12:20:00 【Learning addiction】
Callback function
There are many explanations on the Internet , But the “ return ” Interpreted as “ come back ”, It's hard to understand , in my opinion ,“ return ” Understood as a “ In turn, ” Better , It means the call of role exchange .
Let's explain it :
The program is divided into Applications and Library function
When developing applications, we often call library functions , At this time, if the parameters of the library function require you to pass in a function defined by yourself , The library function will call the function you wrote later , And this process is made up of
You call library functions Turned into The library function calls the function you write , in my opinion , This role exchange is called “ Callback function ” What's the essence of .
Look at it from another Angle , The application belongs to the high level , Library functions belong to the bottom , Generally speaking , yes High level call low level , Now the reverse is Low level calls high level , This transformation of hierarchical roles also reflects “ return ” The meaning of the word calling in reverse
( This is a network diagram , Cut a random one , The source is unknown , It can help understand the calling process )

significance :
Understand the essence of callback function , His significance is obvious , That is to embed your own code into the underlying function ( Or library functions ) in , Because the underlying function ( Or library functions ) It is encapsulated before application development , Some functions need to vary from person to person , What shall I do? ? So only the interface can be preserved , Pass the user-defined function in the form of parameters , Library functions call custom functions in turn , The callback function is just the embodiment of this form .
ps: I've heard of hook functions before (hook), I don't quite understand , It may also achieve a similar effect .
边栏推荐
猜你喜欢

Industry case | how does the index help the sustainable development of Inclusive Finance in the banking industry

Introduction to FPGA (III) - 38 decoder

MySQL组合索引(多列索引)使用与优化

Implementation of dynamic and static libraries (packaging dynamic and static libraries for others to use)

Pytest interface automation test framework | pytest configuration file

干货|语义网、Web3.0、Web3、元宇宙这些概念还傻傻分不清楚?(中)

Problems encountered in byte stream exercises and Solutions

FPGA入门学习(三)- 38译码器

2、 Container_

HTAP comes at a price
随机推荐
【Mysql约束】
Pytest interface automation test framework | execute use cases through markup expressions
Overseas app push (Part 2): Channel Integration Guide for overseas manufacturers
HCIP-9.OSPF的各种拓展
行业案例|指标中台如何助力银行业普惠金融可持续发展
STM32驱动HC05蓝牙串口通信模块
Some common writing methods and skills
Redis为什么这么快?Redis的线程模型与Redis多线程
HTAP是有代价的
《多线程下ThreadLocal使用场景实例》
大量if else判断如何优化?@Valib详解
MATLAB中strjoin函数使用
详解勒让德变换与共轭函数
2、 Container_
面试官:如何理解QPS,TPS,RT?
Redis master-slave replication principle
pytest接口自动化测试框架 | pytest常用插件
面试官:如何处理高并发?
14.2 byte stream learning
[wechat applet] read the article, data request