View mode: basic / threaded / horizontal-split · Log in · Help
November 30, 2007
std.intrinsic and structs
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.
November 30, 2007
Re: std.intrinsic and structs
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.
November 30, 2007
Re: std.intrinsic and structs
"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!
December 03, 2007
Re: std.intrinsic and structs
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
December 03, 2007
Re: std.intrinsic and structs
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
December 03, 2007
Re: std.intrinsic and structs
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
December 06, 2007
Re: std.intrinsic and structs
"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
Top | Discussion index | About this forum | D home