It's UWAweek 47

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


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

Login to reply

👍?
helpful
12:48pm Mon 26th Aug, Chenjun H.

Hi, Just had a few questions about the assignment.

First, what should happen if divide by zero occurs, are we expected to do static analysis at compile time, throw an error at run time, or is it UB?

Second, in example 5 a function call is done using printsum 12 6, without any brackets or separators in the function call, whilst all other examples use function(args) as the syntax. Should we be able to parse both?

Also, with respect to command line arguments, should our program check if the number of arguments passed to the program is sufficient and print to stderr like follows

if (argcount < 2) {
        fprintf(stderr, "%s: program expected at least 1 argument",
                argvalue[0]);
        exit(EXIT_FAILURE);
    }

Thanks in advance.


SVG not supported

Login to reply

👍?
helpful
4:47pm Mon 26th Aug, Christopher M.

Hello,

"Chenjun Hou" [email protected] wrote:

First, what should happen if divide by zero occurs, are we expected to do static analysis at compile time, throw an error at run time, or is it UB?

The focus of the project is not on designing and fully implementing a mini-language - it's 'only' about performing a quite mechanical syntactic translation from one language to another (C11), compiling, and then executing the program. The goals of the project are to encourage you to learn, and then assess your understanding of some core concepts listed on the project's description. In short, it's about C and operating-systems, not language design.

So, there's no need to worry about the division-by-zero cases - implement something if you wish (full static analysis will near impossible without execute the program at compile-time), but division-by-zero won't be tested.

Second, in example 5 a function call is done using printsum 12 6, without any brackets or separators in the function call, whilst all other examples use function(args) as the syntax. Should we be able to parse both?

Thanks; corrected.

Also, with respect to command line arguments, should our program check if the number of arguments passed to the program is sufficient and print to stderr like follows

This is the 2nd point of the 'Project requirements'.


SVG not supported

Login to reply

👍?
helpful
10:20pm Mon 26th Aug, Chenjun H.

Thank you for the clarifications.

My question about argument checking was poorly worded. It is clear to me that runml should perform argument checking, what I meant to ask was whether the ml scripts compiled by our program should perform argument checking as well. For example if a ml script is as follows,

print arg0 + arg1
```. 
Should we assume that all arguments will be provided or should we generate C code to check if 2 arguments are provided? Additionally, does ```arg0``` in ml represent the name of the executable like ```argv[0]`` does in C or is it the first real number argument provided?

Sorry for the inconvenience.


SVG not supported

Login to reply

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

"Chenjun Hou" [email protected] wrote:

My question about argument checking was poorly worded. It is clear to me that runml should perform argument checking, what I meant to ask was whether the ml scripts compiled by our program should perform argument checking as well.

A good question (but, unfortunately, something I was hoping would be recognised as something that "should be done", rather than "must be done"). Yes.

The ml variable arg0 'comes from' C's argv[1], as the C program's name is unlikely to be a real-valued number.


SVG not supported

Login to reply

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

"Christopher McDonald" [email protected] wrote:

The ml variable arg0 'comes from' C's argv[1], as the C program's name is unlikely to be a real-valued number.

Should it not be argv[2], since argv[0] is ./runml (for example) and argv[1] is program.ml?


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

Login to reply

👍?
helpful
8:21am Fri 13th Sep, Joshua N.

ANONYMOUS wrote:

"Christopher McDonald" [email protected] wrote:

The ml variable arg0 'comes from' C's argv[1], as the C program's name is unlikely to be a real-valued number.

Should it not be argv[2], since argv[0] is ./runml (for example) and argv[1] is program.ml?

Yes

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