slang-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] C Structure help ...


> What are the advantages/disadvantages of using passed values
> versus POP'd values ?

The main advantage of explicitly popping arguments from the stack
is flexibility.  For example, it's cleaner/easier to support
functions with a variable number of arguments.

Another reason to choose explicit popping is because it facilitates
custom usage messages.  For example, if your wrapper is coded as

	> apgn_replace(char *value, int *attribute)

and you call it with 0 or 1 arguments then something like

	<stdin>:1:<top-level>:Stack Underflow Error

is returned.  Not terribly helpful.  However, coded as

	> apgn_replace( VOID )

then in the wrapper you can do things like

	if (SLang_Num_Function_Args < SOMETHING ||
	    		  pop_arg_one() == FAIL ||
			  pop_arg_two() == FAIL || ...)

	   emit_helpful_usage_message( ...);

As a concrete example, consider the hypot() intrinsic called
from ISIS (our astrophysical modeling and analysis tool):

	isis> hypot
	<stdin>:1:<top-level>:Stack Underflow Error

If we replace it with a parallel version generated by SLIRP

	isis> import("phypot")

and again call it with no arguments

	isis> hypot
	Usage:  double = hypot(double,double)
	        This function has been vectorized and parallelized.

the result is much more useful, no?

Hope This Helps,
Mike



[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]