On Thursday, May 10, 2018 06:31:09 Mike Franklin via Digitalmars-d-learn
wrote:
> On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote:
> > Structs don't have that.
>
> Should they?
Honestly, I don't think that classes should have it, but changing it now
would break code (most notably
On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote:
Structs don't have that.
Should they?
On Thursday, May 10, 2018 03:23:50 Mike Franklin via Digitalmars-d-learn
wrote:
> My understanding is that nested structs have an implicit context
> pointer to their containing scope.
A non-static struct inside a function does, but I suspect that you're
thinking about non-static nes
?
Thanks,
Mike
My understanding is that nested structs have an implicit
context pointer to their containing scope.
Nesting with hidden context pointer is only for nested structs
inside functions.
https://dlang.org/spec/struct.html#nested
This is a source a confusion unfortunately.
;` then of course it
emits the following error:
Error: no property `x` for type `SS`
My understanding is that `SS` should have a context pointer to an
instance of `S`, but how do I navigate the members of `S` and
`SS`. Is this a bug?
Thanks,
Mike
My understanding is that nested structs have an
On 2013-12-11 23:45, Gary Willoughby wrote:
How to handle nested structs when converting C headers?
In the following snippet i'm currently converting, how would you convert
the nested typed union and structures? Would you declare them separately
then use their types in the Tcl_Obj struct?
Regan Heath:
I would stop nesting the struct definition. I think that is
both cleaner and closer to the original intent - the only
reason it is nested in C is because C allows definition and
declaration that way, and D does not. Then you don't need
static at all.
It's mostly a matter of s
internalRep
>
>
>try
>
>static union InternalRep { /* note the capital letter */
> /* snip */
>}
>InternalRep internalRep;; // still need a decl
Right. But why use the static keyword here?
Because nested structs by default carry a pointer to the containing
struct (
t; >try
> >
> >static union InternalRep { /* note the capital letter */
> > /* snip */
> >}
> >InternalRep internalRep;; // still need a decl
>
> Right. But why use the static keyword here?
Because nested structs by default carry a pointer to the containing
struct
On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe
wrote:
On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby
wrote:
static union internalRep
try
static union InternalRep { /* note the capital letter */
/* snip */
}
InternalRep internalRep;; // still need a decl
Adam D. Ruppe:
Well, you can if it is anonymous.
struct Foo {
union {
struct { ubyte a; ubyte b; }
ubyte[2] arr;
}
}
That works in D, and it makes foo.a == arr[0] and foo.b ==
arr[1];
Right :-) I like D structs.
Bye,
bearophile
On Wednesday, 11 December 2013 at 23:36:11 UTC, bearophile wrote:
In D you can't define a struct/union and use it to define an
instance on the fly.
Well, you can if it is anonymous.
struct Foo {
union {
struct { ubyte a; ubyte b; }
ubyte[2] arr;
}
}
That works in D, an
Gary Willoughby:
Have you got an example because i always get:
tcl.d(713): Error: no identifier for declarator twoPtrValue
tcl.d(718): Error: no identifier for declarator ptrAndLongRep
tcl.d(719): Error: no identifier for declarator internalRep
In D you can't define a struct/union and use it
On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby
wrote:
static union internalRep
try
static union InternalRep { /* note the capital letter */
/* snip */
}
InternalRep internalRep;; // still need a decl
On Wednesday, 11 December 2013 at 23:27:57 UTC, Gary Willoughby
wrote:
On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile
wrote:
Adam D. Ruppe:
Nested structs and unions like in your example are supported
in D too, same syntax, same effect.
But don't forget to add to use &q
On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile wrote:
Adam D. Ruppe:
Nested structs and unions like in your example are supported
in D too, same syntax, same effect.
But don't forget to add to use "static struct" instad of
"struct".
Bye,
bearophile
Adam D. Ruppe:
Nested structs and unions like in your example are supported in
D too, same syntax, same effect.
But don't forget to add to use "static struct" instad of "struct".
Bye,
bearophile
On Wednesday, 11 December 2013 at 22:54:04 UTC, Adam D. Ruppe
wrote:
Nested structs and unions like in your example are supported in
D too, same syntax, same effect.
Actually, no, not quite the same syntax, I didn't notice the name
at the end of the C one (in D, the anonymous nested st
On Wednesday, 11 December 2013 at 22:45:35 UTC, Gary Willoughby
wrote:
How to handle nested structs when converting C headers?
Nested structs and unions like in your example are supported in D
too, same syntax, same effect.
How to handle nested structs when converting C headers?
In the following snippet i'm currently converting, how would you
convert the nested typed union and structures? Would you declare
them separately then use their types in the Tcl_Obj struct? or is
there a nice way in D to nest them l
On Wednesday, March 07, 2012 16:37:44 H. S. Teoh wrote:
> On Wed, Mar 07, 2012 at 03:49:26PM -0800, H. S. Teoh wrote:
> > I wrote a whole bunch of documentation for a struct that I later decided
> > to transplant inside another struct (because the two are closely
> > linked), and now the former str
On Wed, Mar 07, 2012 at 03:49:26PM -0800, H. S. Teoh wrote:
> I wrote a whole bunch of documentation for a struct that I later decided
> to transplant inside another struct (because the two are closely
> linked), and now the former struct's docs have vanished. Is this
> expected behaviour?
[...]
A
I wrote a whole bunch of documentation for a struct that I later decided
to transplant inside another struct (because the two are closely
linked), and now the former struct's docs have vanished. Is this
expected behaviour?
T
--
I am a consultant. My job is to make your job redundant. -- Mr Tom
ine a unit.
I know I am not on the right mailing group, but I want to ask for this
particular language enhancement. I believe this would make the
behavior of the language more straight wrt nested structs inside
classes (are not these beasts expected to serve like nested classes or
even s
truct.html
Nested Structs: A nested struct is a struct that is declared inside the
scope of a function or a templated struct that has aliases to local
functions as a template argument. Nested structs have member functions.
It has access to the context of its enclosing scope (via an added
hi
Steven Schveighoffer:
> A struct nested in a class does not have a hidden "outer" pointer as a
> nested class does.
But I think this will eventually change, once this part is implemented:
http://www.digitalmars.com/d/2.0/struct.html
>Nested Structs: A nested struct
asses, but not for nested structs. Why so?
A struct nested in a class does not have a hidden "outer" pointer as a
nested class does. It's because a struct is generally more bare-bones
than a class (which has loads of hidden pieces: vtable, interfaces,
classinfo, etc.). Also, in
Greetings All
I have a situation where I have a struct nested inside a class. I
would like to make the enclosing class' members visible inside the
nested struct's constructor. I see that such preposition is feasible
for nested classes, but not for nested structs. Why so?
Are
Daniel Keep Wrote:
>
> Tested with 1.035; it works just fine.
>
> -- Daniel
Hmmm... I updated my DMD (it was 1.033) and fixed a miswritten import
statement. That seems to have cleared up the error I was getting.
Thank you Daniel.
--Chris
CodexArcanum wrote:
> Hey all, I'm trying to rewrite a few .h files into D so I can call a C
> library. One snag I've hit is this guy:
>
> struct _tree_t {
> _tree_t* next;
> _tree_t* father;
> _tree_t* sons;
> }
>
> D won't do the nested struct thing, so I need to convert thi
Hey all, I'm trying to rewrite a few .h files into D so I can call a C library.
One snag I've hit is this guy:
struct _tree_t {
_tree_t* next;
_tree_t* father;
_tree_t* sons;
}
D won't do the nested struct thing, so I need to convert this into something D
will like, but
31 matches
Mail list logo