www.digitalmars.com         C & C++   DMDScript  

D - VLAs?

reply "Matthew Wilson" <matthew stlsoft.org> writes:
Walter, just wondered whether we can have VLAs (via alloca()) for
fundamental types?

In other words, rather than having to write something like

    bool  lookup(int id, char *buff, inout uint cchBuff);

    uint cchBuff;
    if(lookup(<someid>, null, cchBuff))
    {
        char[]    buff = new char[cchBuff];

        lookup(<someid>, buff, cchBuff);
    }

it'd be nice to have the option of writing

    uint cchBuff;
    if(lookup(<someid>, null, cchBuff))
    {
        char    buff[cchBuff]; // <== This is allocated via alloca()

        lookup(<someid>, buff, cchBuff);
    }

Thoughts?
Sep 13 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bk0m9o$31i7$1 digitaldaemon.com...
 Walter, just wondered whether we can have VLAs (via alloca()) for
 fundamental types?

 In other words, rather than having to write something like

     bool  lookup(int id, char *buff, inout uint cchBuff);

     uint cchBuff;
     if(lookup(<someid>, null, cchBuff))
     {
         char[]    buff = new char[cchBuff];

         lookup(<someid>, buff, cchBuff);
     }

 it'd be nice to have the option of writing

     uint cchBuff;
     if(lookup(<someid>, null, cchBuff))
     {
         char    buff[cchBuff]; // <== This is allocated via alloca()

         lookup(<someid>, buff, cchBuff);
     }

 Thoughts?

I think it's a good idea. Just need more time in the day <g>.
Sep 13 2003
parent "Matthew Wilson" <matthew stlsoft.org> writes:
nw. :)

"Walter" <walter digitalmars.com> wrote in message
news:bk10dd$dj3$3 digitaldaemon.com...
 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bk0m9o$31i7$1 digitaldaemon.com...
 Walter, just wondered whether we can have VLAs (via alloca()) for
 fundamental types?

 In other words, rather than having to write something like

     bool  lookup(int id, char *buff, inout uint cchBuff);

     uint cchBuff;
     if(lookup(<someid>, null, cchBuff))
     {
         char[]    buff = new char[cchBuff];

         lookup(<someid>, buff, cchBuff);
     }

 it'd be nice to have the option of writing

     uint cchBuff;
     if(lookup(<someid>, null, cchBuff))
     {
         char    buff[cchBuff]; // <== This is allocated via alloca()

         lookup(<someid>, buff, cchBuff);
     }

 Thoughts?

I think it's a good idea. Just need more time in the day <g>.

Sep 13 2003