On Wednesday 17 November 2010 23:09:40 bearophile wrote:
> Jonathan M Davis:
> > In C++, I tend to declare all local variables const when I know that they
> > aren't going to need to be altered. I'd like to something similar in D.
> > However, D has both const and immutable. I can see clear differe
Jonathan M Davis:
> In C++, I tend to declare all local variables const when I know that they
> aren't
> going to need to be altered. I'd like to something similar in D. However, D
> has
> both const and immutable. I can see clear differences in how const and
> immutable
> work with regards
On Wednesday 17 November 2010 19:48:30 Matthias Walter wrote:
> Hi,
>
> I'm currently using DMD v2.049 with phobos. I found an old discussion
> about how toString should be designed and how it is supposed to work. As
> the following code does not print out the number, I wonder what is the
>
> cur
In C++, I tend to declare all local variables const when I know that they
aren't
going to need to be altered. I'd like to something similar in D. However, D has
both const and immutable. I can see clear differences in how const and
immutable
work with regards to function parameters and member
Hi,
I'm currently using DMD v2.049 with phobos. I found an old discussion
about how toString should be designed and how it is supposed to work. As
the following code does not print out the number, I wonder what is the
current status of how to implement a toString function for a struct/class:
| au
> void bar(int N, int M)(ref int[N][M] buf) {}
But for a matrix this is often better:
void bar(int N, int M)(ref int[N][M] buf) {
Or even:
pure void bar(int N, int M)(ref const int[N][M] buf) {
Bye,
bearophile
Matthias Pleh:
> So I solved it with:
>
> void bar(char* buf, int width, int height)
>
> Good old C :)
Most times this is not a good D solution :-(
This compiles (but it created a new instantiation of bar for each different
input matrix):
void bar(int N, int M)(int[N][M] buf) {}
void main()
Dnia 17-11-2010 o 22:38:50 Jonathan M Davis
napisał(a):
There is no way (as far as I know) to
convert that to a dynamic array of dynamic arrays. As such, the compiler
can't
do it implicitly or explicitly. You can probably create a dynamic array
of
dynamic arrays and assign each of the int
On Wed, 17 Nov 2010 22:10:19 +0100
Matthias Pleh wrote:
> void foo(char[] a) {}
> void bar(char[][] b) {}
>
> int main(string[] args)
> {
> char[4] a;
> char[4][4] b;
> foo(a);// OK: implicit convertion
> bar(b);// Error: cannot implicitly convert
>
Am 17.11.2010 22:36, schrieb Steven Schveighoffer:
[...]
two ways, if you want to support multiple lengths of 4-element char arrays, you
could do:
void bar(char[4][])
if you want to support only a 4x4 array, you can do:
void bar(ref char[4][4])
If you want to pass by value, omit the ref, but
Dnia 17-11-2010 o 22:32:21 Tomek Sowiński napisał(a):
What's best to pass such multidimensional arrays?
Good question. Maybe new char[][](4) and point the inner arrays to the
chunks of the static array?
Correction, it can be allocated on the stack:
char[4][4] b;
char[][4] helper
On 17/11/2010 21:10, Matthias Pleh wrote:
void foo(char[] a) {}
void bar(char[][] b) {}
int main(string[] args)
{
char[4] a;
char[4][4] b;
foo(a); // OK: implicit convertion
bar(b); // Error: cannot implicitly convert
// char[4u][4u] to char[][]
}
what is the reason for the different behaviour?
On Wednesday 17 November 2010 13:10:19 Matthias Pleh wrote:
> void foo(char[] a) {}
> void bar(char[][] b) {}
>
> int main(string[] args)
> {
> char[4] a;
> char[4][4] b;
> foo(a);// OK: implicit convertion
> bar(b);// Error: cannot implicitly convert
>
Matthias Pleh Wrote:
> void foo(char[] a) {}
> void bar(char[][] b) {}
>
> int main(string[] args)
> {
> char[4] a;
> char[4][4] b;
> foo(a);// OK: implicit convertion
> bar(b);// Error: cannot implicitly convert
> //char[4u][4u] to
Matthias Pleh napisał(a):
void foo(char[] a) {}
void bar(char[][] b) {}
int main(string[] args)
{
char[4] a;
char[4][4] b;
foo(a);// OK: implicit convertion
bar(b);// Error: cannot implicitly convert
//char[4u][4u] to char[][]
}
void foo(char[] a) {}
void bar(char[][] b) {}
int main(string[] args)
{
char[4] a;
char[4][4] b;
foo(a);// OK: implicit convertion
bar(b);// Error: cannot implicitly convert
//char[4u][4u] to char[][]
}
what is the reason for the differe
16 matches
Mail list logo