From: defaria@hpclapd.HP.COM (Andy DeFaria)
Subject: Re: Stylistic question: returning strings vs. pointers to strings
Date: 6 Mar 90 17:32:59 GMT [thread overview]
Message-ID: <920019@hpclapd.HP.COM> (raw)
In-Reply-To: 10968@june.cs.washington.edu
>/ hpclapd:comp.lang.ada / ka@cs.washington.edu (Kenneth Almquist) / 3:19 pm Mar 5, 1990 /
>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;
My question would be why the package mytypes? Why not:
package ARGS is
type ARG_PTR is access STRING;
function NARGS return integer;
function ARG (index: integer) return ARG_PTR;
end ARGS;
It is a tendency for C programmers to use packages as #include files. In
my opinion this causes confusion. This example creates a string pointer
called ARG_PTR but by its usage it can only point to an command line
arguement.
next prev parent reply other threads:[~1990-03-06 17:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-03-05 23:19 Stylistic question: returning strings vs. pointers to strings Kenneth Almquist
1990-03-06 17:32 ` Andy DeFaria [this message]
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