In the following example, when a test closure is passed as a function parameter, it does not require @escaping. Does this mean that it is considered the closure of noescape? I am wondering if this will work to avoid heap allocation caused by escaping.
func test() { print("hello") } class b<T> { let closure: T // does not requires init(c: @escaping () -> Void) init(c: T) { self.closure = c } } var c = b(c: test)
Does this mean that it is considered the closure of noescape?
, . , (init(c:) ) - , . @escaping, (.. , ) ( SE-0103).
init(c:)
@escaping
, , , , . , , .
test. , , .
test
, - , , placeholder T, Swift thunk . , , ( Q & A).
T
, thunk (, ), , .
, noescape?
.
, , , . , , . :
class Test { var closure: Any init(c: ()->Void) { self.closure = c //Error: Non-Ecaping parameter 'c' may only be called } }
(T), , T . , , .
, , , .
: - . , , ", ".
Source: https://habr.com/ru/post/1667216/More articles:Проверьте значение HttpRequestMessage.Content после вызова PostAsync - .netThe tensorflow feed_dict key cannot be interpreted as a tensor - pythonFranz LISP to Common LISP conversion 2 - macros that generate macros - macrosIs primitive type considered JSON? - jsonJub Stubbing window functions - javascriptWindows GitLab CI Runner using Bash - windowsSSIS Script Задача - подключение ADO.NET и заполнение DataTable - c#Does Julia have a statement that looks like a Haskell dollar sign? - haskellHow to print 95 and 99 Percentiles in jmeter aggregate report command line? - jmeterResponsiveVoice.js does not work with Phonegap compiler - javascriptAll Articles