cdshaw@watmum.UUCP (Chris Shaw) (04/19/85)
>> >>function p(var i:integer):integer; >> >>begin >> p := i; >> i := i+1; >>end (* p *); > >I don't have the original article handy, but it almost looks like someone >was trying to perform the illegal: > > function p(var i:integer):integer; > >which would be an attempt at declaring a function which returns two values. >I pray that somewhere there isn't a compiler which would accept that. >-- >Name: John Ruschmeyer You should hope no such thing !!!! If you find a Pascal compiler which won't accept this program fragment, THROW IT OUT, IT'S WRONG ! Many's the time I've written Pascal functions in the vein above. Quite simply, it is a very easy way to make functions which have error checking as in C. Thus: function x( var i : integer ) : boolean ; begin blah blah blah ; x := error status (success/fail); end; begin { main program } if( x( y ) )then play with y end. Is a much more natural and useful way of saying the same thing with procedures using multiple arguments. (And, yes I tested this, so I'm not just blabbering ) The upshot.. If you're going to talk about a language, learn it first ! Chris Shaw University of Waterloo
sjk@aicchi.UUCP (Ksiazek) (04/23/85)
The point all us "real" programmers are trying to make is , don't go flamming off at the mouth at a really decent language (Pascal) is you don't know what you are talking about. Net.flame doesn't get forwarded here does it? Pascal gives you a choice of either "call-by-name" or "call-by-value". C forces you to use "call-by-value". Many C programmers try to simulate call by name using pointers in the argument list. Of course, I personally would never do (as shown in K & R I think) #define BEGIN { #define END } Steven Ksiazek ...!ihnp4!aicchi!sjk
guido@boring.UUCP (04/23/85)
C A N Y O U P A S C A L W I Z A R D S (:-) P L E A S E K E E P Y O U R D I S C U S S I O N S O U T O F net.lang.c ! ! ? ? ! !
moss@Brl-Vld.ARPA (Gary S. Moss (AMXBR-VLD-V)) (04/24/85)
First of all, you mean call-by-reference, call-by-name is a sick concept. Anyway, passing the address of a variable as an argument is not a simulation of call-by-reference, it is simply stating what you want done explicitly rather than being euphemistic. It does require that you understand pointers, but you have no business using 'C' if you don't. -moss
hansen@mips.UUCP (Craig Hansen) (04/25/85)
> The point all us "real" programmers are trying to make is , > don't go flamming off at the mouth at a really decent language (Pascal) > is you don't know what you are talking about. > > Pascal gives you a choice of either "call-by-name" or "call-by-value". > C forces you to use "call-by-value". Many C programmers try to simulate > call by name using pointers in the argument list. Pascal gives you the choices of 1) Call by value 2) Call by reference C lets you "use" 1) Call by value 2) Call by reference (using "&" constructs and pointers) 3) Call by name (using macros as function definitions) Call by name and call by reference are two very different things! Craig Hansen MIPS Computer Systems
chris@umcp-cs.UUCP (Chris Torek) (04/25/85)
Actually, call-by-name is a very interesting method of parameter passing. How else can you get proc foo (i, j : integer); begin i := 10; bar (j) end; ... foo (x, a[x]); to work when you haven't initialized x yet? :-) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
brooks@lll-crg.ARPA (Eugene D. Brooks III) (04/25/85)
> > The point all us "real" programmers are trying to make is , > don't go flamming off at the mouth at a really decent language (Pascal) > is you don't know what you are talking about. Net.flame doesn't get forwarded > here does it? > > Pascal gives you a choice of either "call-by-name" or "call-by-value". > C forces you to use "call-by-value". Many C programmers try to simulate > call by name using pointers in the argument list. Of course, I personally > would never do (as shown in K & R I think) > > #define BEGIN { > #define END } > > > Steven Ksiazek > ...!ihnp4!aicchi!sjk Could we PLEASE move this discussion to either net.pascal or net.dev.null