[net.lang.c] Gosub

cottrell@NBS-VMS.ARPA (COTTRELL, JAMES) (03/05/86)

/*
> In basic there is a GOSUB routine that will push the current
>  position onto the stack and jump to another line.  Then, upon
>  hitting a return will return to that place.  I wish to write
>  something like that in C that will be movable between compilers.
> 
> A sample of something like it is below:
> 
> [Example Deleted]
> 
> Can anybody think of a better way to do this? I want it for a
>   Basic->C translator (Please, I am writting it for fun... No abuse...Please?).

To answer a somewhat different question, while I am opposed to this
construct in C (because it messes with the stack, making things 
difficult), I would very much like to see this in shell command files.
Here, there is no stack, and variables would be global to the command 
file. I feel that the overhead of opening another file and the
difficulty of passing back results (`cmd args` is limited) justifies it.
What say ye? 

	jim		cottrell@nbs
*/
------

ggs@ulysses.UUCP (Griff Smith) (03/08/86)

> /*
> > In basic there is a GOSUB routine that will push the current
> >  position onto the stack and jump to another line.  Then, upon
> >  hitting a return will return to that place.  I wish to write
> >  something like that in C that will be movable between compilers.
> > 
> > [[Example Deleted] Deleted]
> 
> To answer a somewhat different question, while I am opposed to this
> construct in C (because it messes with the stack, making things 
> difficult), I would very much like to see this in shell command files.
> Here, there is no stack, and variables would be global to the command 
> file. I feel that the overhead of opening another file and the
> difficulty of passing back results (`cmd args` is limited) justifies it.
> What say ye? 
> 
> 	jim		cottrell@nbs
> */
Sorry jim, we're ahead of you.  It's called "function", and it's in
both the System V shell and the Korn shell.  You probably missed it
because you were looking for it under "funx" in the manual pages.
-- 

Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		(201) 582-7736
Internet:	ggs@ulysses.uucp
UUCP:		ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )

kwh@bentley.UUCP (KW Heuer) (03/11/86)

In article <1511@brl-smoke.ARPA> cotrell@nbs writes:
>>To answer a somewhat different question, while I am opposed to [gosub]
>>in C ... I would very much like to see this in shell command files.
>>... I feel that the overhead of opening another file and the
>>difficulty of passing back results (`cmd args` is limited) justifies it.

and in article <1201@ulysses.UUCP> ulysses!ggs answers:
>Sorry jim, we're ahead of you.  It's called "function"...

Now if only shell function calls didn't destroy the $* variable, they might
be useful.

ggs@ulysses.UUCP (Griff Smith) (03/11/86)

> In article <1511@brl-smoke.ARPA> cotrell@nbs writes:
> >>To answer a somewhat different question, while I am opposed to [gosub]
> >>in C ... I would very much like to see this in shell command files.
> >>... I feel that the overhead of opening another file and the
> >>difficulty of passing back results (`cmd args` is limited) justifies it.
> 
> and in article <1201@ulysses.UUCP> ulysses!ggs answers:
> >Sorry jim, we're ahead of you.  It's called "function"...
> 
> Now if only shell function calls didn't destroy the $* variable, they might
> be useful.

True, for the System V shell.  Ksh saves and restores $* correctly, and
functions are definitely useful.
-- 

Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		(201) 582-7736
Internet:	ggs@ulysses.uucp
UUCP:		ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )

rbj@icst-cmr (Root Boy Jim) (03/12/86)

	From: Griff Smith <ulysses!ggs>
	Subject: Re: Gosub
	
	Sorry jim, we're ahead of you.  It's called "function", and it's in
	both the System V shell and the Korn shell.  You probably missed it
	because you were looking for it under "funx" in the manual pages.
	
	Griff Smith	AT&T (Bell Laboratories), Murray Hill
	
No, I missed it because I'm not familiar with obscure versions of UNIX :-)

daemon@houligan.UUCP (04/01/86)

>    > /*
>    > > In basic there is a GOSUB routine that will push the current
>    > >  position onto the stack and jump to another line.  Then, upon
>    > >  hitting a return will return to that place.  I wish to write
>    > >  something like that in C that will be movable between compilers.
>    > > 
>    > > [[Example Deleted] Deleted]
>    > 
>    > To answer a somewhat different question, while I am opposed to this
>    > construct in C (because it messes with the stack, making things 
>    > difficult), I would very much like to see this in shell command files.
>    > Here, there is no stack, and variables would be global to the command 
>    > file. I feel that the overhead of opening another file and the
>    > difficulty of passing back results (`cmd args` is limited) justifies it.
>    > What say ye? 
>    > 
>    > 	jim		cottrell@nbs
>    > */
>    Sorry jim, we're ahead of you.  It's called "function", and it's in
>    both the System V shell and the Korn shell.  You probably missed it
>    because you were looking for it under "funx" in the manual pages.
>    -- 
>    
>    Griff Smith	AT&T (Bell Laboratories), Murray Hill
>    Phone:		(201) 582-7736
>    Internet:	ggs@ulysses.uucp
>    UUCP:		ulysses!ggs  ( {allegra|ihnp4}!ulysses!ggs )

cccsam@ucdavis.UUCP (Sam McCall - Hacker In Residency) (04/03/86)

apparently a major malfunction... :-)


-- 
-sam mccall
-unix consultant
-computer center
-university of california, davis
-...{lll-crg,ucbvax}!ucdavis!deneb!cccsam
-...ucdavis!deneb!cccsam@ucbvax.berkeley.edu

Cherry.XSIS@Xerox.COM (04/04/86)

I've received the same message 14 times now...That's enough.  Your GOSUB seems to work!

B.C. & Zot

levy@ttrdc.UUCP (Daniel R. Levy) (04/06/86)

PLEASE STOP THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
There were 48 copies of this on my system this afternoon.
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
						vax135}!ttrdc!levy