It's UWAweek 37 (2nd semester, week 7)

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 the 4 articles in this topic
Showing 4 of 409 articles.
Currently 3 other people reading this forum.


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful

Hi, my project partner and I have just had a discussion and came back with a few questions/assumptions that we wanted to check about the syntax of ml. 1 .Is it possible to have cases where functions and variables in ml share the same identifier while still being separate entities? Or do they have to be wholly unique? 2. Do parameters behave like they do in C, rather than in Python where variables passed to a function via one of its parameters can be directly updated by said function? (ie a function has a variable x, that it passes to another function which then updates the value of x in the original function). 3. Each line is one statement, does this mean variable initialisations are limited to one per line, or can one line have multiple variable initialisations on it? If so, what does this look like (are they separated by commas?) and also, concerning the project brief page itself: 4. What is meant by point 8 on the “Our ml language” section of the project page? Do arg0, arg1, etc. refer to arguments passed to the main() function of the c file/code we create by translating a given ml file? Clarifications would be greatly appreciated.


SVG not supported

Login to reply

👍?
helpful
6:27am Tue 27th Aug, Christopher M.

ANONYMOUS wrote:
> 1 .Is it possible to have cases where functions and variables in ml share the same identifier while still being separate entities? Or do they have to be wholly unique?
No - you cannot introduce a new function if its name is already used as a variable's name, or introduce a new variable if its name is already used as a function's name.
> 2. Do parameters behave like they do in C, rather than in Python where variables passed to a function via one of its parameters can be directly updated by said function? (ie a function has a variable x, that it passes to another function which then updates the value of x in the original function).
Parameters are passed as they are in C. A copy of an actual parameter's value is used to initialise a function's formal parameter. This is termed pass-by-value (and is the only parameter passing mechanism in C).
> 3. Each line is one statement, does this mean variable initialisations are limited to one per line, or can one line have multiple variable initialisations on it? If so, what does this look like (are they separated by commas?)
There are no 'variable initialisation' statements, only assignment statements, and each statement appears on its own line.
> and also, concerning the project brief page itself: > 4. What is meant by point 8 on the “Our ml language” section of the project page? Do arg0, arg1, etc. refer to arguments passed to the main() function of the c file/code we create by translating a given ml file?
When the compiled C program is executed, its runtime command-line arguments are available in ml's arg0, arg1, ... Hope this helps,


SVG not supported

Login to reply

👍?
helpful
12:44pm Thu 29th Aug, ANONYMOUS

"Christopher McDonald" <ch*i*.*c*o*a*d@u*a*e*u*a*> wrote:
> ANONYMOUS wrote: > > > 1 .Is it possible to have cases where functions and variables in ml share the same identifier while still being separate entities? Or do they have to be wholly unique? > > No - you cannot introduce a new function if its name is already used as a variable's name, or introduce a new variable if its name is already used as a function's name.
Can it be assumed that function parameters cannot share an identifier with variables outside the function either?


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

Login to reply

👍?
helpful

ANONYMOUS wrote:
> "Christopher McDonald" <ch*i*.*c*o*a*d@u*a*e*u*a*> wrote: > > > ANONYMOUS wrote: > > > > > 1 .Is it possible to have cases where functions and variables in ml share the same identifier while still being separate entities? Or do they have to be wholly unique? > > > > No - you cannot introduce a new function if its name is already used as a variable's name, or introduce a new variable if its name is already used as a function's name. > > Can it be assumed that function parameters cannot share an identifier with variables outside the function either?
Best to ask Amitava.

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