It's UWAweek 51

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


 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported

Login to reply

👍?
helpful
8:53pm Mon 2nd Sep, Mark LN.

That would be hard to do without building a full-blown syntax parser, how would you figure out how many parameters are in this function call: function_name((x+1)-2, function2((a-1),b))


SVG not supported

Login to reply

👍?
helpful
8:02am Wed 4th Sep, Joshua N.

"Mark Le Noury" <23*6*4*5@s*u*e*t*u*a*e*u*a*> wrote:
> That would be hard to do without building a full-blown syntax parser, how would you figure out how many parameters are in this function call: > > function_name((x+1)-2, function2((a-1),b))
I'm not sure if it is necessary but it does sound like fun (if you're me anyway). You could check the number of arguments by counting the number of commas and the number of open brackets without a closing bracket. If number of open brackets is 1, then count the commas, otherwise ignore the commas. E.g. the number of commas counted in the above expression would be 1, so there are 2 parameters total.


SVG not supported

Login to reply

👍?
helpful
8:10am Wed 4th Sep, Joshua N.

I should also mention you'd likely need to recursively "check" functions, e.g. If you're checking the parameters and encounter another function, start checking the new function. But like I said I'm not sure if it is necessary.


SVG not supported

Login to reply

👍?
helpful
6:45pm Wed 4th Sep, Mark LN.

"Joshua Noble" <22*6*9*8@s*u*e*t*u*a*e*u*a*> wrote:
> "Mark Le Noury" <23*6*4*5@s*u*e*t*u*a*e*u*a*> wrote: > > > That would be hard to do without building a full-blown syntax parser, how would you figure out how many parameters are in this function call: > > > > function_name((x+1)-2, function2((a-1),b)) > > I'm not sure if it is necessary but it does sound like fun (if you're me anyway). > > You could check the number of arguments by counting the number of commas and the number of open brackets without a closing bracket. If number of open brackets is 1, then count the commas, otherwise ignore the commas. E.g. the number of commas counted in the above expression would be 1, so there are 2 parameters total.
what happens when the function takes a string as a parameter and the string contains bracket and commas? e.g. call_function("This will break, your idea (maybe?)")


SVG not supported

Login to reply

👍?
helpful
7:12pm Wed 4th Sep, Joshua N.

"Mark Le Noury" <23*6*4*5@s*u*e*t*u*a*e*u*a*> wrote:
> "Joshua Noble" <22*6*9*8@s*u*e*t*u*a*e*u*a*> wrote: > > > "Mark Le Noury" <23*6*4*5@s*u*e*t*u*a*e*u*a*> wrote: > > > > > That would be hard to do without building a full-blown syntax parser, how would you figure out how many parameters are in this function call: > > > > > > function_name((x+1)-2, function2((a-1),b)) > > > > I'm not sure if it is necessary but it does sound like fun (if you're me anyway). > > > > You could check the number of arguments by counting the number of commas and the number of open brackets without a closing bracket. If number of open brackets is 1, then count the commas, otherwise ignore the commas. E.g. the number of commas counted in the above expression would be 1, so there are 2 parameters total. > > > > what happens when the function takes a string as a parameter and the string contains bracket and commas? e.g. call_function("This will break, your idea (maybe?)")
Yes, that would break my cool idea. However, we can still fix it, just keep track of the quotes too. If we saw a quote ignore everything until we see another quote. Unfortunately, ml only supports real numbers, which makes me sad as this circumstance will never occur.

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