id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	lang	patch	platform
1991	simplify 'new_callback' op	jimmy		"Hello,
    I would like to simplify 'new_callback' op. first please see https://github.com/parrot/parrot/blob/master/t/pmc/nci.t#L1545-#L1606-1551.
    there are lines:

{{{
    .local pmc user_data
    user_data = new ['Integer']
    user_data = 42

    # A Sub that can be given to the library
    # this callback function will eventually by called by the library
    .const 'Sub' cb = ""_call_back""
    .local pmc cb_wrapped
    cb_wrapped = new_callback cb, user_data, ""vtU""  # Z in pdd16
    print ""created a callback sub\n""

    # now call the external sub, that takes a callback and user data
    .local pmc libnci_test
    libnci_test = loadlib ""libnci_test""
    .local pmc nci_cb_C1
    nci_cb_C1 = dlfunc libnci_test, ""nci_cb_C1"", ""vpP""
    print ""loaded a function that takes a callback\n""
    nci_cb_C1( cb_wrapped, user_data )

}}}


passing the value of user_data into new_callback is useless and unused, because it's finally invoked and used by this code:

{{{
nci_cb_C1( cb_wrapped, user_data )
}}}


So consider:

{{{
    .local pmc user_data
    user_data = new ['Integer']

    # A Sub that can be given to the library
    # this callback function will eventually by called by the library
    .const 'Sub' cb = ""_call_back""
    .local pmc cb_wrapped
    user_data = 42
    cb_wrapped = new_callback cb, user_data, ""vtU""  # Z in pdd16
    print ""created a callback sub\n""

    # now call the external sub, that takes a callback and user data
    .local pmc libnci_test
    libnci_test = loadlib ""libnci_test""
    .local pmc nci_cb_C1
    nci_cb_C1 = dlfunc libnci_test, ""nci_cb_C1"", ""vpP""
    print ""loaded a function that takes a callback\n""
    user_data = 44   # user_data is changed here.
    nci_cb_C1( cb_wrapped, user_data )

}}}

so passing user_data = 42 to new_callback is redundant, I would like to simplify it to this one:

{{{
    cb_wrapped = new_callback cb, ""vtU""
}}}

"	RFC	closed	normal		none	3.0.0	medium	wontfix					
