It's UWAweek 42 (2nd semester, week 12)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 738 articles.
Currently 171 other people reading this forum.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
7:13am Sat 14th Sep, Joshua N.

"Chenjun Hou" [email protected] wrote:

By passing a function as a parameter to another function, I mean

function exec a
    return a()
#
function seven
    return 7
#
print exec(seven)

Here we pass the function seven to the function exec as its a parameter, and the ``exec``` function executes it, ultimately resulting in 7 being printed.

Is this behavior allowed in ml? If it is, how do we get around c's function type checking? I believe that to pass a function to a function, its necessary to create a function pointer like so void func ( void (*f)(int) );.

Also with respect to functions with the same name, should we assume it never happens or check it?

No ml doesn't allow passing a function to a function. It is too complex for this project, and I don't believe it will be covered in the unit.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy