www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.intrinsic and structs

reply "Jaheera" <no spam.com> writes:
I had some questions about the std.intrinsic functions:

Is it possible to do bt, bts and btr operations on ulongs as is already 
possible on uints?

Why do the intrinsic operations not return bool, instead of 0 and -1?


I also have a question about structs.

I want to do this, but this obviously doesn't work:

struct foo(int var)
{
    int[var] x;
}

struct bar
{
    foo[4] zeb(10);
}

Thanks. 
Nov 30 2007
next sibling parent reply Chad J <gamerChad _spamIsBad_gmail.com> writes:
Jaheera wrote:
 
 I also have a question about structs.
 
 I want to do this, but this obviously doesn't work:
 
 struct foo(int var)
 {
     int[var] x;
 }
 
 struct bar
 {
     foo[4] zeb(10);
 }
 
 Thanks. 
 
 

I /think/ what you want is this: struct foo(int var) { int[var] x; // static array of 'var' elements } struct bar { /* static array of 4 elements containing foos that contain static arrays of 10 elements. */ foo!(10)[4] zeb; } I'm sorry I don't know if I'm actually helping. I don't entirely understand the question.
Nov 30 2007
parent "Jaheera" <no spam.com> writes:
"Chad J" <gamerChad _spamIsBad_gmail.com> wrote in message 
news:fipmho$ivc$1 digitalmars.com...
 Jaheera wrote:
 I also have a question about structs.

 I want to do this, but this obviously doesn't work:

 struct foo(int var)
 {
     int[var] x;
 }

 struct bar
 {
     foo[4] zeb(10);
 }

 Thanks.

I /think/ what you want is this: struct foo(int var) { int[var] x; // static array of 'var' elements } struct bar { /* static array of 4 elements containing foos that contain static arrays of 10 elements. */ foo!(10)[4] zeb; } I'm sorry I don't know if I'm actually helping. I don't entirely understand the question.

Actually you understood it perfectly, this appears to be exactly what i needed, thanks!
Nov 30 2007
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
Jaheera wrote:
 I had some questions about the std.intrinsic functions:
 
 Is it possible to do bt, bts and btr operations on ulongs as is already 
 possible on uints?

No. Though I suppose there's an outside chance we will get this feature once DMD can compile 64-bit code.
 Why do the intrinsic operations not return bool, instead of 0 and -1?

Walter has historically had an aversion to bool return values (opEquals, for example) because he felt that they were inefficient. I believe someone once demonstrated that this isn't actually true, but I'll be darned if I can find the thread. Sean
Dec 03 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Sean Kelly wrote:
 Jaheera wrote:
 I had some questions about the std.intrinsic functions:

 Is it possible to do bt, bts and btr operations on ulongs as is 
 already possible on uints?

No. Though I suppose there's an outside chance we will get this feature once DMD can compile 64-bit code.
 Why do the intrinsic operations not return bool, instead of 0 and -1?

Walter has historically had an aversion to bool return values (opEquals, for example) because he felt that they were inefficient. I believe someone once demonstrated that this isn't actually true, but I'll be darned if I can find the thread. Sean

I think the thread is linked to from one of the Doc comments pages. Probably the one for wherever opEquals and opCmp are described. --bb
Dec 03 2007
parent reply Sean Kelly <sean f4.ca> writes:
Bill Baxter wrote:
 Sean Kelly wrote:
 Jaheera wrote:
 I had some questions about the std.intrinsic functions:

 Is it possible to do bt, bts and btr operations on ulongs as is 
 already possible on uints?

No. Though I suppose there's an outside chance we will get this feature once DMD can compile 64-bit code.
 Why do the intrinsic operations not return bool, instead of 0 and -1?

Walter has historically had an aversion to bool return values (opEquals, for example) because he felt that they were inefficient. I believe someone once demonstrated that this isn't actually true, but I'll be darned if I can find the thread.

I think the thread is linked to from one of the Doc comments pages. Probably the one for wherever opEquals and opCmp are described.

You're right. I'm pretty sure it was this thread/comment. I could have sworn that Walter had replied to the one I was thinking of, but I must be misremembering: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=8005 Sean
Dec 03 2007
parent "Jaheera" <no spam.com> writes:
"Sean Kelly" <sean f4.ca> wrote in message 
news:fj201d$261a$1 digitalmars.com...
 Bill Baxter wrote:
 Sean Kelly wrote:
 Jaheera wrote:
 I had some questions about the std.intrinsic functions:

 Is it possible to do bt, bts and btr operations on ulongs as is already 
 possible on uints?

No. Though I suppose there's an outside chance we will get this feature once DMD can compile 64-bit code.
 Why do the intrinsic operations not return bool, instead of 0 and -1?

Walter has historically had an aversion to bool return values (opEquals, for example) because he felt that they were inefficient. I believe someone once demonstrated that this isn't actually true, but I'll be darned if I can find the thread.

I think the thread is linked to from one of the Doc comments pages. Probably the one for wherever opEquals and opCmp are described.

You're right. I'm pretty sure it was this thread/comment. I could have sworn that Walter had replied to the one I was thinking of, but I must be misremembering: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=8005 Sean

I see. Thanks for the clarification
Dec 06 2007