www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - TDPL error(s)

reply Timon Gehr <timon.gehr gmx.ch> writes:
On page 263, TDPL states that struct objects nested inside a function cannot
be returned, because the caller does not have access to their types. Using the
auto keyword, DMD lets you do this though. Is this a bug in DMD or an error in
TDPL?

On the same page, the assert should be
assert(Local.sizeof == size_t.sizeof + int.sizeof);

rather than
assert(Local.sizeof == 2*size_t.sizeof);

which always fails in 64 bit.


Timon
May 08 2011
next sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Sun, 08 May 2011 17:59:02 +0400, Timon Gehr <timon.gehr gmx.ch> wrote:

 On page 263, TDPL states that struct objects nested inside a function  
 cannot
 be returned, because the caller does not have access to their types.  
 Using the
 auto keyword, DMD lets you do this though. Is this a bug in DMD or an  
 error in
 TDPL?

I think that's fine.
 On the same page, the assert should be
 assert(Local.sizeof == size_t.sizeof + int.sizeof);

 rather than
 assert(Local.sizeof == 2*size_t.sizeof);

 which always fails in 64 bit.


 Timon

Without looking at the code, I'd assume that Local is defined something like this: struct Local { size_t s; int i; } in which case Local.sizeof would most likely be size_t.sizeof * 2 because of the alignment and implicit padding, i.e 8 bytes on x86, and 16 bytes on x64. size_t.sizeof + int.sizeof only give 12. I'd agree that this is in fact confusing and needs to be explained.
May 08 2011
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
 On Sun, 08 May 2011 17:59:02 +0400, Timon Gehr <timon.gehr gmx.ch> wrote:

 On page 263, TDPL states that struct objects nested inside a function
 cannot
 be returned, because the caller does not have access to their types.
 Using the
 auto keyword, DMD lets you do this though. Is this a bug in DMD or an
 error in
 TDPL?

I think that's fine.

Being fine is not an option. They contradict each other.
 Without looking at the code, I'd assume that Local is defined something
 like this:

 struct Local
 {
  size_t s;
  int i;
 }

 in which case Local.sizeof would most likely be size_t.sizeof * 2 because
 of the alignment and implicit padding, i.e 8 bytes on x86, and 16 bytes on
 x64. size_t.sizeof + int.sizeof only give 12.

 I'd agree that this is in fact confusing and needs to be explained.

I see. After further reading, the alignment of structs is indeed explained.
May 08 2011
prev sibling parent dolive <dolive89 sina.com> writes:
Denis Koroskin Wrote:

 On Sun, 08 May 2011 17:59:02 +0400, Timon Gehr <timon.gehr gmx.ch> wrote:
 
 On page 263, TDPL states that struct objects nested inside a function  
 cannot
 be returned, because the caller does not have access to their types.  
 Using the
 auto keyword, DMD lets you do this though. Is this a bug in DMD or an  
 error in
 TDPL?

I think that's fine.
 On the same page, the assert should be
 assert(Local.sizeof == size_t.sizeof + int.sizeof);

 rather than
 assert(Local.sizeof == 2*size_t.sizeof);

 which always fails in 64 bit.


 Timon

Without looking at the code, I'd assume that Local is defined something like this: struct Local { size_t s; int i; } in which case Local.sizeof would most likely be size_t.sizeof * 2 because of the alignment and implicit padding, i.e 8 bytes on x86, and 16 bytes on x64. size_t.sizeof + int.sizeof only give 12. I'd agree that this is in fact confusing and needs to be explained.

Why ddmd don‘t continue ? Give up ?
May 08 2011
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 5/8/11 8:59 AM, Timon Gehr wrote:
 On page 263, TDPL states that struct objects nested inside a function cannot
 be returned, because the caller does not have access to their types. Using the
 auto keyword, DMD lets you do this though. Is this a bug in DMD or an error in
 TDPL?

Bug in TDPL.
 On the same page, the assert should be
 assert(Local.sizeof == size_t.sizeof + int.sizeof);

 rather than
 assert(Local.sizeof == 2*size_t.sizeof);

 which always fails in 64 bit.

Thanks, added to the errata: http://erdani.com/tdpl/errata Andrei
May 08 2011
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:iq6h8h$1ph2$1 digitalmars.com...
 Thanks, added to the errata: http://erdani.com/tdpl/errata

Speaking of errata related to TDPL, I'm getting this in FF and IE: http://www.semitwist.com/download/tdplerrata.png And the breadcrumb links at the top aren't clickable. It works in Iron. In Opera, the big white rectangle is missing.
May 08 2011
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 5/8/11 2:10 PM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:iq6h8h$1ph2$1 digitalmars.com...
 Thanks, added to the errata: http://erdani.com/tdpl/errata

Speaking of errata related to TDPL, I'm getting this in FF and IE: http://www.semitwist.com/download/tdplerrata.png And the breadcrumb links at the top aren't clickable. It works in Iron. In Opera, the big white rectangle is missing.

Thanks, I'll look into it. What version of FF and what OS? Andrei
May 08 2011
parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:iq6qth$286t$1 digitalmars.com...
 On 5/8/11 2:10 PM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:iq6h8h$1ph2$1 digitalmars.com...
 Thanks, added to the errata: http://erdani.com/tdpl/errata

Speaking of errata related to TDPL, I'm getting this in FF and IE: http://www.semitwist.com/download/tdplerrata.png And the breadcrumb links at the top aren't clickable. It works in Iron. In Opera, the big white rectangle is missing.

Thanks, I'll look into it. What version of FF and what OS?

Heh, uh, well, FF2 ;) And IE7 (I like to keep IE at 7 so I can test my sites on it.) WinXP. Opera is 10.62
May 08 2011
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
What the heck.. scrolling through this new layout completely maxes out
an entire core and makes the browser very sluggish. What is that page
doing, protein folding?

I'm on FF 3.6.16, XP32.
May 08 2011