C Programming Research Paper !!! 
Author Message
 C Programming Research Paper !!!

        As silly as this may sound, I have an instructor requiring our
class (3 students) to write a 5 page research paper on a particular "C"
topic.  My topic is "function calls".  Would anyone know where I might
find information on this particular subject?  Thank you in advance!!!


Thu, 15 May 1997 04:50:01 GMT  
 C Programming Research Paper !!!

Quote:

>    As silly as this may sound, I have an instructor requiring our
> class (3 students) to write a 5 page research paper on a particular "C"
> topic.  My topic is "function calls".  Would anyone know where I might
> find information on this particular subject?  Thank you in advance!!!

Go to your library and find 3-4 books on C. They probably all have a chapter
about declaring and calling functions !

                                                                   Arne

Arne Vajh?j                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE

                WWW URL: http://www.hhs.dk/~arne/arne.html



Thu, 15 May 1997 22:01:34 GMT  
 C Programming Research Paper !!!

Quote:

>    As silly as this may sound, I have an instructor requiring our
>class (3 students) to write a 5 page research paper on a particular "C"
>topic.  My topic is "function calls".  Would anyone know where I might
>find information on this particular subject?  Thank you in advance!!!

The academic oriented term for the way fucntion calls are implemented
in C is "call by value".  You might research that topic in your library.
C is different from some other procedural languages in that the function
is the only sub-unit of code.  There is no "subroutine" or "procedure"
that does not return a value.   Hence the need to consider a return-type
of every C function even if you intend to always ignore it's value.
You might want to mention that allows recursive function calls (not all
languages do).   C supports functions that have variable arguments.  
Discussing how C syntax supports variable arguments should be good for at
least a page!  Function calls are made using expressions denoting the
function to be called.  These expressions can be simple names of functions,
but can be more complex, involving expressions that have a value that
is a pointer to a function.  This mechanism is fundamental to an object-
oriented programming philosophy.  So, because of this aspect of function
calling, object-oriented programming is done frequently (and easily once
mastered) using C.    The order of evaluation of arguments to the function
is an interesting topic to research.   There is an assignment-like
conversion that takes place when the value of an argument is passed
to the function.  Discuss that phenomenon both with and without function
prototypes available.   A so-called "sequence-point" is defined after
the arguments are evaluated, and before the actual call.  Discuss the
implication of that.

Enough for now....
--

214/888-0471



Sun, 18 May 1997 00:53:13 GMT  
 C Programming Research Paper !!!

Quote:

>    As silly as this may sound, I have an instructor requiring our
>class (3 students) to write a 5 page research paper on a particular "C"
>topic.  My topic is "function calls".  Would anyone know where I might
>find information on this particular subject?  Thank you in advance!!!

Sounds silly to me -- why would an instructor want you to show that you
had learned something?  Anyway, if you *have* to do this exercise, maybe
you could try your class notes, or your textbooks, or maybe just catch a
few waves?

--



Sun, 18 May 1997 01:28:36 GMT  
 C Programming Research Paper !!!

Quote:


>>       As silly as this may sound, I have an instructor requiring our
>>class (3 students) to write a 5 page research paper on a particular "C"
>>topic.  My topic is "function calls".  Would anyone know where I might
>>find information on this particular subject?  Thank you in advance!!!

You might consider when is a function call not a function call.
Lots of texts say that if you've got this

int func(int, int);
int x;
x  = func(1,2);

then func could in fact turn out to be a macro, viz
#define func(a,b)       another_func(x,y)
or
#define func(a,b)       ((a) + (b))

They then say that you can prevent this by writing
x = (func)(1,2);

This mostly works. But even this might not be as it appears. Consider

int  func_doppel_gang( int a, int b )
        {
        return a+b;
        }

int (*func_ghost(void))(int, int)
        { /* func_ghost returns a pointer to a "func-like" function */
        return func_doppel_gang;
        }

#define func    (*func_ghost())

With this chicanery in place, a line like ....

x = func(1,2);

will turn out to be

x = (*func_ghost())(1,2);

Some points to note on this are
1. You must do
#define func    (*func_ghost())
and not
#define func    func_ghost()
because of lines like this
int (*pf)(int, int) = &func;

3. The technique works even if you want a functions address (and not a call)
(see above)

2. The technique works for functions that have variable argument lists
Example

#include <stdarg.h>
#include <stdio.h>
int  printf_doppel_gang( const char * fmt, ... )
        {
        int ret;
        va_list ap;

        va_start(ap, fmt);
        ret = vprintf(fmt, ap);
        va_end(ap);
        return ret;
        }

int (*printf_ghost(void))(const char * fmt, ...)
        { /* ghost returns a pointer to a "func-like" function */
        return printf_doppel_gang;
        }

#define printf  (*printf_ghost())

This may have typos in it, I don't have access to a C compiler at the moment.
Its a powerful, but little known technique.
Hope its useful
Cheers
JJ



Sun, 18 May 1997 19:49:51 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Problem #30 on http://cs.nmu.edu/programming/c/problems.htm

3. SoftEng or CS Graduate Program Search

4. FS: Programming and CS Books --- CHEAP

5. 1995 UT IEEE CS National Programming Contest

6. Good CS Programs

7. IEEE CS National Programming Contest [Addendum3]

8. 1993 IEEE CS National Programming Contest Notice

9. Description of The 1991 IEEE CS National Programming Contest

10. 1993 IEEE CS National Programming Contest Addendum 2

11. 1993 IEEE CS National Programming Contest [Addendum]

12. Programming Language for Undergrad Intro CS Course?

 

 
Powered by phpBB® Forum Software