NXC - main method params?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: NXC - main method params?

Post by spillerrec »

I disagree with this kind of classification as it doesn't really provide anything useful for the programmer. We shouldn't classify 'tasks' on their input, output and placement, we should rather classify them based on what they do.

Look at most of NXC functions. They take a struct as input (behind the scenes) and do something with it. This would look like this:

Code: Select all

DrawPointType draw;
draw.Location.X = 5;
draw.Location.Y = 10;
SysDrawPoint( draw );
Now this could easily have been done in a OOP way:

Code: Select all

DrawPointType draw;
draw.Location.X = 5;
draw.Location.Y = 10;
draw.SysDrawPoint();
Now it is no longer a function, but a method.
But let us return to the function viewpoint. It is a function because it returns a char, but this char have literately no importance so we could just remove this. Now it is a procedure. (Seriously, how many checks whether PointOut() successfully drew on the screen or not?)
Many functions can't just be changed to procedures, but many others can because the return value isn't critical to the purpose of the function.

This draw-a-dot 'task' can be a procedure, function or method by making minor modifications which makes no difference for the programmer which writes it or uses it. Then why should we call them something different? If we have to categories 'tasks', then why not do it in a way so it becomes useful for the people that are actually using the code?

Anyway, this is becoming off topic...
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC - main method params?

Post by mightor »

This is a pointless thread now, I suspect someone will invoke Godwin's Law within now and 3 posts, so I am locking it.

There is no single naming convention on what to call these entities, so everyone is right and everyone is wrong and let's just leave it at that.

Image

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Locked

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests