Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!agate!pasteur!cory.Berkeley.EDU!fadden From: fadden@cory.Berkeley.EDU (Andy McFadden) Newsgroups: comp.sys.apple2 Subject: Re: ML subroutines (passing parameters in ML) Message-ID: <13084@pasteur.Berkeley.EDU> Date: 26 Apr 91 17:54:49 GMT References: <3397@kluge.fiu.edu> <13845@ucrmath.ucr.edu> <51983@apple.Apple.COM> Sender: news@pasteur.Berkeley.EDU Reply-To: fadden@cory.Berkeley.EDU Lines: 32 In article <51983@apple.Apple.COM> stadler@Apple.COM (Andy Stadler) writes: >I disagree with your assessment that it's big and slow. There are two tech- >niques which make it quite efficient and useable. The first is to use the >Pascal style of never passing any items greater than 4 bytes long. If a >parameter is longer than 4 bytes, push a pointer to it. This is an area where >Pascal has an edge over C because C is always pushing and pulling huge streams >of bytes on and off the stack (especially when working with strings). Second, Say WHAT?!? No C program I have ever written (which includes NuLib and the usual academic projects like a compiler, an object rendering system, etc) has passed arguments larger than four bytes. Strings are NOT passed as a string, but as a pointer to the string. Many versions of C don't allow entire structures to be passed (APW C is an exception), but instead only allow pointers to them to be passed. Whatever your C compiler allows, pushing and pulling huge streams of stuff off the stack is incredibly inefficient and easy to avoid (heck, it's easier to avoid it than to do it in the first place). There are VERY few cases where you would want to send an entire structure, and in those cases Pascal wouldn't be able to do it at all, so I'd say C has an edge over Pascal. >Andy Stadler >Apple Computer, Inc. -- fadden@cory.berkeley.edu (Andy McFadden) ..!ucbvax!cory!fadden fadden@hermes.berkeley.edu (when cory throws up)