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


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

Login to reply

👍?
helpful
12:08am Thu 12th Sep, ANONYMOUS

once we finished transcribing the ml language into C code in a separate file, I assume we need to call the system function to run shell commands to run the C file right? the problem with this is that we require a main function for it before it compiles right? also how do we deal with the datatypes considering our ml file only accepts float datatypes, even if lets say the file sample contains a: function main argc argv # some code here the main function requires a return value to be int, argc to be int, and argv to be string array. the translation will either be float main(float argc, float argv) {} or void main(float argc, float argv) {} which is incorrect i assume


SVG not supported

Login to reply

👍?
helpful
1:29pm Thu 12th Sep, ANONYMOUS

The ml doesn't need a main because it's not being compiled. It's the temporary C file being compiled which will need a main like every C program.


SVG not supported

Login to reply

👍?
helpful
4:01pm Thu 12th Sep, ANONYMOUS

The ml doesn't need a main because it's not being compiled. It's the temporary C file being compiled which will need a main like every C program.

right, I understand that the temporary C files can just be encapsulated like so (correct me if i'm wrong):


int main(int argc, char *argv[]) {

   // converted c code here

}

but that doesn't really explain how the program can access the arguments, as we don't know what the program is going to refer the argument values as when doing the computing, so we cant really name the main parameters argc and argv right?

unless i'm missing something and it says how the arguments is going to be used in the ml file


SVG not supported

Login to reply

👍?
helpful
9:20pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote:

The ml doesn't need a main because it's not being compiled. It's the temporary C file being compiled which will need a main like every C program.

right, I understand that the temporary C files can just be encapsulated like so (correct me if i'm wrong):


int main(int argc, char *argv[]) {

   // converted c code here

}

but that doesn't really explain how the program can access the arguments, as we don't know what the program is going to refer the argument values as when doing the computing, so we cant really name the main parameters argc and argv right?

unless i'm missing something and it says how the arguments is going to be used in the ml file

You are missing something.

You replace the identifiers (in the ml file) arg0, arg1, arg2, etc. By the command line arguments that are passed to run ml. e.g.

./runml somefile.ml 1 2 3

means that in the ml file the parameters will be initialized as follows. arg0 = 1 arg1 = 2 arg2 = 3


SVG not supported

Login to reply

👍?
helpful
10:09pm Thu 12th Sep, ANONYMOUS

means that in the ml file the parameters will be initialized as follows. arg0 = 1 arg1 = 2 arg2 = 3

okay, so I can assume that the arguments will be accessed under the alias arg0, arg1, .... and not under any other name correct? but wouldn't this contradict the statement where identifier names can only include lowercase alphabetic order?


SVG not supported

Login to reply

👍?
helpful
10:33pm Thu 12th Sep, Joshua N.

ANONYMOUS wrote:

means that in the ml file the parameters will be initialized as follows. arg0 = 1 arg1 = 2 arg2 = 3

okay, so I can assume that the arguments will be accessed under the alias arg0, arg1, .... and not under any other name correct? but wouldn't this contradict the statement where identifier names can only include lowercase alphabetic order?

Technically they're not considered "identifiers" just "variables". So, in other words, they're an exception to the rule. As stated in the project description: "8.the variables arg0, arg1, and so on, provide access to the program's command-line arguments which provide real-valued number."


SVG not supported

Login to reply

👍?
helpful
3:36pm Fri 13th Sep, Amitava D.

ANONYMOUS wrote:
> once we finished transcribing the ml language into C code in a separate file, I assume we need to call the system function to run shell commands to run the C file right? > > the problem with this is that we require a main function for it before it compiles right? also how do we deal with the datatypes considering our ml file only accepts float datatypes, even if lets say the file sample contains a: > > function main argc argv > # some code here > > the main function requires a return value to be int, argc to be int, and argv to be string array. > > the translation will either be > > float main(float argc, float argv) {} > > or > > void main(float argc, float argv) {} > > which is incorrect i assume
I didn't have much time to look at the project carefully. However, main() is also valid in C, without any parameters like argc and argv

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