== Quote from Jacob Carlborg (d...@me.com)'s article
> On 2010-08-06 15:33, Pluto wrote:
> > == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
> >> On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote:
> >>> Are these equivalent?
> >>>
> >>> S s;//struct
> >>>
> >>> void f(ref S s){s.x
On 2010-08-06 15:33, Pluto wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote:
Are these equivalent?
S s;//struct
void f(ref S s){s.x++;}
f(s);
void f2(S* s){(*s).x++;}
f2(&s);
They are pretty much equivalent. I think
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
> On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote:
> > Are these equivalent?
> >
> > S s;//struct
> >
> > void f(ref S s){s.x++;}
> > f(s);
> >
> > void f2(S* s){(*s).x++;}
> > f2(&s);
> They are pretty much equivalent. I think th
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
> On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote:
> > Are these equivalent?
> >
> > S s;//struct
> >
> > void f(ref S s){s.x++;}
> > f(s);
> >
> > void f2(S* s){(*s).x++;}
> > f2(&s);
> They are pretty much equivalent. I think th
On Fri, 06 Aug 2010 08:51:31 -0400, Pluto wrote:
Are these equivalent?
S s;//struct
void f(ref S s){s.x++;}
f(s);
void f2(S* s){(*s).x++;}
f2(&s);
They are pretty much equivalent. I think the code generated actually will
be exactly the same. However, the compiler treats ref differently
Are these equivalent?
S s;//struct
void f(ref S s){s.x++;}
f(s);
void f2(S* s){(*s).x++;}
f2(&s);
If so, why is it stated that ref is very rarely used?
It looks like something I would use a lot with structures.
On 2010-03-20 00.29, bearophile wrote:
(I am looking for rough corners in D, or in my knowledge of D.)
In this page:
http://www.digitalmars.com/d/2.0/templates-revisited.html
In the section "Template Parameters" there is written:
P:P*, // P must be a pointer type
-
So
Daniel Keep:
> You do realise that "Template Parameters" are a completely different
> thing to "is expressions", right?
Nope. And from the other answers by Moritz and Ellery it seems I am not alone
:-)
You are right, this works:
template IsPointer1(T:T*) {
enum bool IsPointer1 = true;
}
tem
bearophile wrote:
> (I am looking for rough corners in D, or in my knowledge of D.)
>
> In this page:
> http://www.digitalmars.com/d/2.0/templates-revisited.html
>
> In the section "Template Parameters" there is written:
>
> P:P*, // P must be a pointer type
>
> -
>
>
Moritz Warning:
>I think the problem is that is(T : T*) becomes is(int* : int**) and that's
>false.<
Thank you, you can be right.
So D docs are wrong, or that syntax has a semantic bug, or I have not
understood the situation yet.
If someone else has ideas I'm all ears.
-
Ellery New
On 03/19/2010 07:53 PM, Moritz Warning wrote:
On Fri, 19 Mar 2010 19:29:24 -0400, bearophile wrote:
(I am looking for rough corners in D, or in my knowledge of D.)
[..]
template IsPointer1(T) {
enum bool IsPointer1 = is(T : T*);
}
void main() {
int* ptr;
static assert(IsPointe
On Fri, 19 Mar 2010 19:29:24 -0400, bearophile wrote:
> (I am looking for rough corners in D, or in my knowledge of D.)
[..]
>
> template IsPointer1(T) {
> enum bool IsPointer1 = is(T : T*);
> }
> void main() {
> int* ptr;
> static assert(IsPointer1!(typeof(ptr))); // Err
> }
>
>
>
(I am looking for rough corners in D, or in my knowledge of D.)
In this page:
http://www.digitalmars.com/d/2.0/templates-revisited.html
In the section "Template Parameters" there is written:
P:P*, // P must be a pointer type
-
So I have written this D2 program:
templa
13 matches
Mail list logo