Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What's new in C? |
| Date | 2012-11-30 16:41 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <k9anj1$iap$1@speranza.aioe.org> (permalink) |
| References | (1 earlier) <796b8c57-33da-4a39-99db-fd252a6c337e@googlegroups.com> <k98ak3$ts6$1@dont-email.me> <k9a2qf$mbh$1@dont-email.me> <028418c2-2b87-47ce-8727-f73fcd408309@googlegroups.com> <k9ahtc$ahl$1@dont-email.me> |
Rui Maciel <rui.maciel@gmail.com> wrote: > Malcolm McLean wrote: >> With a non-recursive function, stack usage can be calculated at >> compile time. Also, f the stack breaks, the sitation is likely to be >> detected on the first run. In the days of fixed sized small stacks, I suppose that is true. Maybe it still is for embedded systems. I remember dynamic stacks back to OS/2 1.2, though. The linker required one to set a stack size if larger than the default 4K, but I could make it really big (more than available virtual memory) and it worked fine. >> That's not the case with vlas. They can only be coded safely by imposing >> a maximum. But if you set the maximum so that the stack cannot overflow >> on any input, normally you must hardcode the maxmium. So there's actually >> not much advantage in a vla. Is it required that VLAs be stack allocated? Stack allocation of large arrays has been a Fortran problem for a long time. There are assumptions, mostly from C, that automatic arrays should be small, which isn't always true. Also, Fortran can sometimes allocate temporary arrays of unknown (at compile time) size. > That's exactly why VLAs, when used properly, can be an improvement over > fixed-length arrays (FLAs). That seems useful to me. Even more, in the case of recursion, you can size each instance as appropriate. > VLAs tend to be depicted as a way to get arrays larger than the one needed > by FLAs, but it's actually the other way around. With VLAs, it's possible > to calll functions which declare arrays that are smaller than what would > otherwise be required by a FLA solution. Therefore, if VLAs are allocated > in the stack, the worst case scenario is that they require as much stack > space as the FLA solution, and in any other case they will take over less > memory than what would otherwise be allocated. This is an improvement, and > can be a significant one, as it reduces the chances of overflowing the call > stack. This might look like nit picking, but high availability is achieved > through nit picking. Well, in the case of recursion, you can never be sure how big the stack needs to be, in cases where recursion depth (and array size) depends on input data. But also, most systems allow changing the stack size without recompiling. > So, along with the syntactic sugar side of VLAs, using them does have its > advantages, and depending on the application and how they are used, they > might actually be significant. Note that PL/I has had variable length AUTO arrays since day zero. (Sometime in the mid 1960's.) (Well, OS/360 doesn't have a stack, so everything was heap allocated. To speed thing up, it would allocate a large (maybe 4K) block and then divide that up among the different DSAs.) In the days of small computers, it may have made sense to allocate small local arrays (of fixed size) on the stack, and large ones on the heap. Other languages never had the same distinction. -- glen
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-11-28 19:41 -0700
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-11-28 19:15 -0800
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-06 02:43 -0700
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-06 07:45 -0500
Re: What's new in C? Noob <root@127.0.0.1> - 2012-11-29 10:36 +0100
Re: What's new in C? Weland <weland@sdf.lonestar.org> - 2012-11-29 10:17 +0000
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-04 01:45 -0700
Re: What's new in C? Weland <weland@sdf.lonestar.org> - 2012-11-29 09:48 +0000
Re: What's new in C? David Brown <david@westcontrol.removethisbit.com> - 2012-11-29 13:50 +0100
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 05:55 -0800
Re: What's new in C? Les Cargill <lcargill99@comcast.com> - 2012-11-29 12:48 -0600
Re: What's new in C? Rui Maciel <rui.maciel@gmail.com> - 2012-11-30 10:46 +0000
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-30 05:31 -0800
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-11-30 14:22 +0000
Re: What's new in C? Rui Maciel <rui.maciel@gmail.com> - 2012-11-30 15:04 +0000
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-11-30 16:41 +0000
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-11-30 11:49 -0500
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-30 10:12 -0800
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-11-30 11:12 -0800
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-11-30 22:26 +0000
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-11-30 22:36 +0000
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-11-30 23:27 +0000
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-04 01:39 -0700
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-04 00:43 -0800
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-04 03:14 -0700
Re: What's new in C? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-04 12:50 +0000
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-12-04 05:54 -0800
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-04 20:51 +0000
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-04 16:09 -0500
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-04 16:19 -0500
Re: What's new in C? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-04 21:45 +0000
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-05 01:13 +0000
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-04 20:36 -0500
Re: What's new in C? Robert Wessel <robertwessel2@yahoo.com> - 2012-12-04 20:26 -0600
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-04 18:48 -0800
Re: What's new in C? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-05 02:57 +0000
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-05 01:42 +0000
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-06 02:06 -0700
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-06 07:50 -0500
Re: What's new in C? JohnF <john@please.see.sig.for.email.com> - 2012-12-06 13:46 +0000
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-06 09:39 -0500
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-11-30 15:52 -0500
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-04 01:53 -0700
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-04 08:16 -0500
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-04 21:18 +0000
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-04 18:04 -0500
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-05 01:19 +0000
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-04 21:05 -0500
Re: What's new in C? Noob <root@127.0.0.1> - 2012-12-05 16:45 +0100
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-06 01:45 -0700
Re: What's new in C? James Kuyper <jameskuyper@verizon.net> - 2012-12-06 08:12 -0500
Re: What's new in C? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-06 21:13 +0000
Re: What's new in C? Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 09:15 -0500
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-12 18:28 -0700
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-11-30 11:22 -0800
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-04 03:04 -0700
Re: What's new in C? Rui Maciel <rui.maciel@gmail.com> - 2012-11-29 18:19 +0000
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 11:41 -0800
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-11-30 20:50 +0000
Re: What's new in C? Jens Gustedt <jens.gustedt@loria.fr> - 2012-11-30 23:35 +0100
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-12-05 03:26 +0000
Re: What's new in C? gwowen <gwowen@gmail.com> - 2012-12-05 23:49 -0800
Re: What's new in C? Cal Dershowitz <cal@example.invalid> - 2012-12-06 01:49 -0700
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-12-08 07:55 +0000
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 13:29 +0000
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-12-08 15:23 +0000
Re: What's new in C? Martin Shobe <martin.shobe@yahoo.com> - 2012-12-08 17:46 +0000
Re: What's new in C? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-12-08 10:45 -0800
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-12-08 19:32 +0000
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 18:55 +0000
Re: What's new in C? Ian Collins <ian-news@hotmail.com> - 2012-12-09 08:26 +1300
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 20:12 +0000
Re: What's new in C? Ian Collins <ian-news@hotmail.com> - 2012-12-09 09:18 +1300
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 21:21 +0000
Re: What's new in C? Ian Collins <ian-news@hotmail.com> - 2012-12-09 10:27 +1300
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-08 13:36 -0800
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-08 12:59 -0800
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 22:10 +0000
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-08 16:15 -0800
Re: What's new in C? Ian Collins <ian-news@hotmail.com> - 2012-12-09 14:23 +1300
Re: What's new in C? Ian Collins <ian-news@hotmail.com> - 2012-12-09 14:20 +1300
Re: What's new in C? Keith Thompson <kst-u@mib.org> - 2012-12-08 11:32 -0800
Re: What's new in C? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-09 02:52 +0000
Re: What's new in C? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-09 02:53 +0000
Re: What's new in C? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-12-08 20:08 +0000
Re: What's new in C? "BartC" <bc@freeuk.com> - 2012-12-08 20:25 +0000
csiph-web