Wrapper function: Difference between revisions

Content deleted Content added
m Bot: http → https
 
(One intermediate revision by one other user not shown)
Line 9:
 
=== Programming convenience ===
Wrapper functions simplify writing computer programs. For example, the <code>MouseAdapter</code> and similar classes in the [[Java AWT]] library demonstrate this.<ref>[httphttps://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html The Java Tutorials]</ref>
They are useful in the development of applications that use third-party library functions. A wrapper can be written for each of the third party functions and used in the native application. In case the third party functions change or are updated, only the wrappers in the native application need to be modified as opposed to changing all instances of third party functions in the native application.
 
Line 34:
Many [[Standard library|library]] functions, such as those in the [[C Standard Library]], act as [[Interface (computing)|interface]]s for [[Abstraction (computer science)|abstract]]ion of [[system call]]s. The ''fork'' and ''execve'' functions in [[glibc]] are examples of this. They call the [[low-level|lower-level]] ''[[Fork (operating system)|fork]]'' and ''[[execve]]'' system calls, respectively.
 
This may lead to incorrectly using the terms "system call" and "syscall" to refer to higher-level library calls rather than the similarly named system calls, which they wrap.<ref>{{Cite web|url=httphttps://man7.org/linux/man-pages/man2/syscalls.2.html|title=syscalls(2) - Linux manual page|website=man7.org|access-date=2020-04-25}}</ref><ref>{{Cite web|url=https://www.gnu.org/software/libc/manual/html_node/System-Calls.html|title=System Calls (The GNU C Library)|website=www.gnu.org|access-date=2020-04-25}}</ref>
 
==Helper function==
A helper function is a function which groups parts of [[computation]] by assigning descriptive names and allowing for the reuse of the computations.<ref>{{cite web|url=https://web.cs.wpi.edu/~cs1101/a05/Docs/creating-helpers.html|archive-url=https://web.archive.org/web/20210507033146/https://web.cs.wpi.edu/~cs1101/a05/Docs/creating-helpers.html|archive-date=7 May 2021|title=CS 1101: Helper functions|first=Kathi|last=Fisler|publisher=[[Worcester Polytechnic Institute]]|year=2005|access-date=17 November 2021|url-status=live}}</ref> Although not all wrappers are helper functions, all helper functions are wrappers, and a notable use of helper functions—grouping frequently utilized operations—is in [[Binary_translation#Dynamic_binary_translation|dynamic binary translation]], in which helper functions of a particular [[Computer architecture|architecture]] are used in translation of [[Machine code|instructions]] from one [[Instruction set architecture|instruction set]] into another.<ref>{{cite conference|title=Helper function inlining in dynamic binary translation|conference= CC: Compiler Construction|publisher=[[Association for Computing Machinery]]|first=Wenwen|last=Wang|doi=10.1145/3446804.3446851|page=107|url=https://dl.acm.org/doi/10.1145/3446804.3446851|___location=New York, United States|isbn=978-1-4503-8325-7|date=3 March 2021|url-access=subscription}}</ref>
 
==See also==