Author: James Swafford
Date: 12:41:43 06/04/05
Go up one level in this thread
On June 03, 2005 at 17:29:32, Dieter Buerssner wrote:
>On June 03, 2005 at 15:28:27, Dann Corbit wrote:
>
>>I think that C99 style automatic arrays are probably a very good way to make
>>lists, and I don't see anyone doing it.
>
>I assume, by "automatic arrays" you mean variable length arrays (VLAs).
>Automatic arrays where available in C since long; long before C99. VLAs are new
>in C99. They indeed are very handy, and I have missed them since long.
>Programmers have used all sort of hacks, to get them before C99. For example by
>using (non portable) alloca().
>
>For those, who are not aware what VLAs can do:
>
>void foo(size_t n)
>{
> int array[n]; /* Not possible in C90, but possible in C99 */
> /* ... */
>}
>
>
>In the context of this discussion, like Gerd at the moment I cannot see a
>concrete use (that is clearly better than old style) of VLAs. But it might give
>small advantages.
>
>One should also be aware of the risk of using VLAs. Gcc does support them (not
>sure, if it already supports them with all consequences in "complicated" cases -
>but certainly for typical usage). Does MSVC 6 support them? I guess not. Do new
>versions of Visual Studio support them? If you want to port your chess engine to
>Palm or Pocket PC - will you find a compiler that supports VLAs (and other C99
>features)? I myself prefer to wait a bit, before I want my code to be dependent
>on C99 features. I recently learned, that new Visual Studio does support some
>new C99 features. Others will follow. Gcc was faster already for many things.
>So, perhaps, no need to wait for very long.
>
>Are VLAs in C++? Java?
In the java.util library there is a 'Vector' type. You simply add
objects to your Vector using the addElement( ) method. It takes
care of the rest for you.
Conversely, you can remove elements using removeElement( ).
There is also an ArrayList type that is (I think) about the same
thing.
--
James
>
>Cheers,
>Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.