It's UWAweek 44 (2nd semester, 1st exam week)

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 821 articles.
Currently 16 other people reading this forum.


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

Login to reply

👍?
helpful
8:21pm Wed 11th Sep, Joshua N.

"Harrison Lisle" [email protected] wrote:

Hello,

I've just posted another article, but thought I should separate these for clarity.

First of all, similar questions have already been asked in my article as well as this article by anon.

That is: If a function has been initialised with no return, if called in an expression is it invalid, or can we safely equate it to zero. Do all functions have a decimal return type with a default of zero, or are there also void functions?

Second of all, ML seems to be relatively strict about scope (see part 12 of "Our ml Language"):

"a function's parameters and any other identifiers used in a function body are local to that function, and become unavailable when the function's execution completes"

So, can a function modify variables defined above its scope? As in, in the ML code:

a <- 3

function dosomething
	a <- a + 2

print a

Will the output be 3, or 5? Can function dosomething modify the variable defined before it, or only use it as in sample 8?

Thank you.

I believe it is fine to return zero if a function doesn't have a return value.

Amitava please respond to the second question.

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