'goto" gone from computer languages or is it!
Vintage Computer Festival
vcf at siconic.com
Mon May 16 18:06:51 CDT 2005
On Mon, 16 May 2005, John Hogerhuis wrote:
> On 5/16/05, Sean 'Captain Napalm' Conner <spc at conman.org> wrote:
>
> > Hmmm ...
> >
> > void print_arg(int *aryp,size_t n)
> > {
> > printf("%u",*aryp++);
> > while(--n)
> > {
> > printf(",%u",*aryp++);
> > }
> > putchar('\n');
> > }
> >
> > -spc (avoids additional variables, no GOTOs, and one conditional ... )
> >
> >
>
>
> <<THUMP>> (spc just hit in the forehead by an eraser).
>
> Straighten up and get serious. You used twice as much printf as
> everybody else. Have you ever seen the setup for a printf call in
> assembler?
>
> I wonder if even the compiler can save you from this shameless bit of excess.
I trump thee collectively:
void print_arg(int *aryp, size_t n)
{
char *t="%u,";
int i=0;
for (;(i==n-1 ? t="%u" : i<n);) printf(t, *aryp + i++);
putchar('\n');
}
A little ugly (the compiler complains about the type mismatch in the unary
expression) but otherwise it works without caveats (that I know of ;)
I suspect someone might bum it down further...no more precious time to
expend on this useless pursuit ;)
--
Sellam Ismail Vintage Computer Festival
------------------------------------------------------------------------------
International Man of Intrigue and Danger http://www.vintage.org
[ Old computing resources for business || Buy/Sell/Trade Vintage Computers ]
[ and academia at www.VintageTech.com || at http://marketplace.vintage.org ]
More information about the cctalk
mailing list