February 05, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a3nvlr$2f0q$4@digitaldaemon.com... > > "Pavel Minayev" <evilone@omen.ru> wrote in message news:a3mr4l$1hrf$1@digitaldaemon.com... > > Also, when will we get array constants? > > When I spend less time reading this newsgroup and more time working <g>. With the latest 30 msgs per day traffic, I guess we won't get it till Christmas =) |
February 05, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to D | "D" <s_nudds@hotmail.com> wrote in message news:a3np7r$2ce2$1@digitaldaemon.com... > Can I sue you when your program crashes? Hm? |
February 05, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to D | "D" <s_nudds@hotmail.com> wrote in message news:a3o71m$2it6$1@digitaldaemon.com... > > Pavel Minayev <evilone@omen.ru> wrote in message news:a3lkv0$spm$1@digitaldaemon.com... > > Also, variants are still better that printf() anarchy. > > Only if you rid the language of the printf statment. > > What you are really saying is that varints simplify the passing of multiple > variables of indeterminate type to a function. > > They do. To the extent that youi don't have to worry about variable type as > long as all your variables are the same size. You still have the issue of passing multiple variables though. > > The better solution of course, is to abandon the C method of passing muliple > variables to a function and create something more rational. > > I would define a protocol whereby the called variable argument function would be provided with the argument count and a single pointer to a structure holding the data that was passed. The format of that structure would be... Could be much simpler. Since D has dynamic arrays, they can be used. Syntax could be something like this: void printfi[int] { for (int i = 0; i < args.length; i++) // args is an array of arguments ... } printfi(1, 2, 3); Also, if we have array literals, there's no great need in this: void printfi(int[] args) { ... } printfi([1, 2, 3]); |
February 05, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Yes, well the above code (first example) processed different variable types rhat than a single variable type. The second example is simply another way of doing it via a variable # of arguments. In your example you have chosen to passs a single variable (the array) rather than a set of variables. Pavel Minayev <evilone@omen.ru> wrote in message news:a3od3j$2l9o$1@digitaldaemon.com... > Could be much simpler. Since D has dynamic arrays, they can be used. Syntax could be something like this: > > void printfi[int] > { > for (int i = 0; i < args.length; i++) // args is an array of > arguments > ... > } > > printfi(1, 2, 3); > > Also, if we have array literals, there's no great need in this: > > void printfi(int[] args) { ... } > > printfi([1, 2, 3]); > > |
February 05, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to D | "D" <s_nudds@hotmail.com> wrote in message news:a3pg7t$5bu$1@digitaldaemon.com... > Yes, well the above code (first example) processed different variable types > rhat than a single variable type. It didn't. 1, 2 and 3 are all ints. > The second example is simply another way of doing it via a variable # of arguments. In your example you have chosen to passs a single variable (the > array) rather than a set of variables. What I suggest is that dynamic array would be implicitly used to implement safe varargs - since it stores its length. |
February 06, 2002 Re: variants | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | > "D" <s_nudds@hotmail.com> wrote in message news:a3pg7t$5bu$1@digitaldaemon.com... > > Yes, well the above code (first example) processed different variable > types > > rhat than a single variable type. Pavel Minayev <evilone@omen.ru> wrote in message news:a3pi4b$6lu$1@digitaldaemon.com... > It didn't. 1, 2 and 3 are all ints. My code processed variables of different types in the first example and the same type in the second. I have presented a solution that doesn't require varints. basically the programmer has to walk a structure to pick up the variables. The question is, is this burden to the programmer worth the extra effort of including varints in the language itself. I don't think so in my opinion, unless there is some other compelling reason for varints that I am not immediately aware of. > > The second example is simply another way of doing it via a variable # of arguments. In your example you have chosen to passs a single variable > (the > > array) rather than a set of variables. Pavel Minayev <evilone@omen.ru> wrote in message news:a3pi4b$6lu$1@digitaldaemon.com... > What I suggest is that dynamic array would be implicitly used to implement safe varargs - since it stores its length. Certainly that would be more convenient. But are varints worth it? |
Copyright © 1999-2021 by the D Language Foundation