From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!mit-eddie!uw-beaver!uw-june!ka From: ka@cs.washington.edu (Kenneth Almquist) Newsgroups: comp.lang.ada Subject: Stylistic question: returning strings vs. pointers to strings Message-ID: <10968@june.cs.washington.edu> Date: 5 Mar 90 23:19:17 GMT Organization: U of Washington, Computer Science, Seattle List-Id: 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