From: ka@cs.washington.edu (Kenneth Almquist)
Subject: Stylistic question: returning strings vs. pointers to strings
Date: 5 Mar 90 23:19:17 GMT [thread overview]
Message-ID: <10968@june.cs.washington.edu> (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
next reply other threads:[~1990-03-05 23:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-03-05 23:19 Kenneth Almquist [this message]
1990-03-06 17:32 ` Stylistic question: returning strings vs. pointers to strings 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox