comp.lang.ada
 help / color / mirror / Atom feed
* Stylistic question: returning strings vs. pointers to strings
@ 1990-03-05 23:19 Kenneth Almquist
  1990-03-06 17:32 ` Andy DeFaria
  0 siblings, 1 reply; 5+ messages in thread
From: Kenneth Almquist @ 1990-03-05 23:19 UTC (permalink / raw)


Here's a question about programming style for you to debate.  I have a
package which accesses command line arguments.  My current implementa-
tion is for systems without the concept of a command line arguments;
it reads the command arguments from the standard input.  The interface
to the package consists of two functions:

	nargs - returns the number of command line arguments.
	arg(i) - returns the i'th command line argument.

Being a former C programmer, I naturally made arg(i) return a pointer
to a string, using a separate package named mytypes to contain the
definition of a pointer to a string:

	package mytypes is
	    type string_ptr is access string;
	end mytypes;

	with mytypes; use mytypes;
	package args is
	    function nargs return integer;
	    function arg(index: integer) return string_ptr;
	end args;

Since I haven't been exposed to a lot of Ada programming styles, I'd
be curious to hear from people who would specify the interface differ-
ently, for example making arg(i) return a string rather than a pointer
to a string, or making "arg" a procedure with an "out" argument like
"get_line".
				Kenneth Almquist

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1990-03-09  3:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-03-05 23:19 Stylistic question: returning strings vs. pointers to strings Kenneth Almquist
1990-03-06 17:32 ` Andy DeFaria
1990-03-07 22:25   ` Robert I. Eachus
1990-03-08 14:14     ` Terry J. Westley
1990-03-09  3:16       ` Bryce Bardin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox