digitalmars.D - a few (newbish?) questions about D...
- Claydoo (18/18) May 07 2004 Hi, I have a few simple questions about D.
- Vathix (11/29) May 07 2004 equals 2?
- Unknown W. Brackets (5/9) May 07 2004 I read it as wondering why the order is changed... I have no answer for
- Mike Wynn (14/38) May 07 2004 consider the C
Hi, I have a few simple questions about D. First off, why is it that if i run 'mydprogram one_arg', args.length equals 2? Something i'm missing? seems like just one argument was passed. Does the name as the program count as an argument? Second off, in C arrays are declared in the order of short bob[numarrays:2][num_vars_per_array:3] = { {1,2,3}, {1,2,3} }; why does D take such a different approach with short [num_vars_per_array:3][numarrays:2] = [ [1,2,3], [1,2,3] ]; Is there something really useful i'm missing here? It seems like it just makes it harder to convert C++ code to D, and as a c/c++ guy it is just confusing.
May 07 2004
"Claydoo" <Claydoo_member pathlink.com> wrote in message news:c7gp9d$1ch8$1 digitaldaemon.com...Hi, I have a few simple questions about D. First off, why is it that if i run 'mydprogram one_arg', args.lengthequals 2?Something i'm missing? seems like just one argument was passed. Does thename asthe program count as an argument?That's correct, args[0] is the program name used.Second off, in C arrays are declared in the order of short bob[numarrays:2][num_vars_per_array:3] = { {1,2,3}, {1,2,3} }; why does D take such a different approach with short [num_vars_per_array:3][numarrays:2] = [ [1,2,3], [1,2,3] ]; Is there something really useful i'm missing here? It seems like it justmakesit harder to convert C++ code to D, and as a c/c++ guy it is justconfusing. D's way makes it easier to parse. Encounter [], it's an array; {}, it's a struct. -- Christopher E. Miller
May 07 2004
Vathix wrote:short bob[numarrays:2][num_vars_per_array:3] =(should be short [num_vars_per_array:3][numarrays:2] *bob* =, no?)short [num_vars_per_array:3][numarrays:2] =D's way makes it easier to parse. Encounter [], it's an array; {}, it's a struct.I read it as wondering why the order is changed... I have no answer for that, however, but I assume there's likely a reason. -[Unknown]
May 07 2004
On Fri, 7 May 2004 15:56:40 -0400, "Vathix" <vathixSpamFix dprogramming.com> wrote:"Claydoo" <Claydoo_member pathlink.com> wrote in message news:c7gp9d$1ch8$1 digitaldaemon.com...consider the C typedef int IA[4] typedef IA myData[3] IA is int[4] myData is (int[4])[3] or int myData[3][4] <- more confusing if its more complex as in : int[][char[]][] is array of ( assoc(key=char[], value=int[]) ) something[] where something is val[key] with val=int[], key=char[] simple to mix arrays of arrays of hashes od arrays of hashes of ...... may seem odd if you come from a C background, but once you use it you'll never look back. Mike.Hi, I have a few simple questions about D.Second off, in C arrays are declared in the order of short bob[numarrays:2][num_vars_per_array:3] = { {1,2,3}, {1,2,3} }; why does D take such a different approach with short [num_vars_per_array:3][numarrays:2] = [ [1,2,3], [1,2,3] ]; Is there something really useful i'm missing here? It seems like it justmakesit harder to convert C++ code to D, and as a c/c++ guy it is justconfusing.
May 07 2004