November 09, 2005 Re: symbol aliasing in structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ivan Senji | "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message news:dkqgot$2jhf$1@digitaldaemon.com... > Wouldn't return by reference simplify these cases where property doesn't > need to do any real task except get or set? > Something like: > inout bit fldA() { return foo[0]; } > > Is there any chance for this ever to be in D? Doing references to bits will require more than just a pointer, it'll have to be a pointer plus a bit number. Then, these won't work like regular pointers. There really isn't a good solution, it's just an issue of where are the seams going to trip you. |
November 09, 2005 Re: symbol aliasing in structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message
> news:dkqgot$2jhf$1@digitaldaemon.com...
>
>>Wouldn't return by reference simplify these cases where property doesn't
>>need to do any real task except get or set?
>>Something like:
>>inout bit fldA() { return foo[0]; }
>>
>>Is there any chance for this ever to be in D?
>
>
> Doing references to bits will require more than just a pointer, it'll have
> to be a pointer plus a bit number. Then, these won't work like regular
> pointers. There really isn't a good solution, it's just an issue of where
> are the seams going to trip you.
<flame on>
At risk of sounding like a bitching old lady:
So even here the bit datatype is not _genuinely_ supported by the language!
Either this kind of things should work uniformly with the other integral datatypes (syntactically, that is), or we should consider skipping bit as a separate data type altogether.
This would save us from a lot of pretense, and it would let the specification be changed to "bool is implemented internally as the fastest or most convenient integer type, but cast to or from bool is implicitly rewritten as
return (value == 0) ? 0 : 1;
By this time D is _sexy_ enough to not anymore need such arcane marketing pranks as "bit datatype".
Also, even this discussion should serve as an example of the confusion and frustration and misunderstanding and unwarranted hopes, that this pretense fosters.
<grrrrr>
|
November 09, 2005 Re: symbol aliasing in structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message > news:dkqgot$2jhf$1@digitaldaemon.com... > >>Wouldn't return by reference simplify these cases where property doesn't >>need to do any real task except get or set? >>Something like: >>inout bit fldA() { return foo[0]; } >> >>Is there any chance for this ever to be in D? > > > Doing references to bits will require more than just a pointer, it'll have > to be a pointer plus a bit number. Why not? > Then, these won't work like regular pointers. So what? Pointers to bits are not regular pointers and trying to classify them as pointers is wrong. I like the idea of bit type and find that it could be usefull, but as it is now to many things can not be done with them. I wouldn't have anything against bit* being 2*size_t, plus some rules of casting bit* to normal pointers. > There really isn't a good solution, it's just an issue of where > are the seams going to trip you. > I didn't understand this part, but i have to say i wasn't trying to start a bit-war, i was just thinking and trying to say how returning refereces would be a really nice feature. It is probably the *only* thing i miss from C++. |
November 09, 2005 Re: symbol aliasing in structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ivan Senji | "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message news:dksr7t$t4b$1@digitaldaemon.com... > Walter Bright wrote: > > Doing references to bits will require more than just a pointer, it'll have > > to be a pointer plus a bit number. > Why not? > > Then, these won't work like regular pointers. > > So what? Pointers to bits are not regular pointers and trying to classify them as pointers is wrong. I guarantee that, if implemented, there will be issues because it can't be converted back and forth between void*. |
November 09, 2005 Re: symbol aliasing in structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message
> news:dksr7t$t4b$1@digitaldaemon.com...
>
>>Walter Bright wrote:
>>>Then, these won't work like regular pointers.
>>
>>So what? Pointers to bits are not regular pointers and trying to
>>classify them as pointers is wrong.
>
>
> I guarantee that, if implemented, there will be issues because it can't be
> converted back and forth between void*.
>
Yes, but you can call a well documented issue a feature :)
bit[8] bits; //located on adress 0xABCDEFGH
bit* bitptr = &bit[1]; // bitptr == {0xABCDEFGH, 1};
void* voidptr = cast(void*)bitptr; //voidptr = {0xABCDEFGH}
bitptr* = cast(bit*)voidptr; //bitptr == {0xABCDEFGH, 0};
And it doesn't feel souch a big issue.
|
Copyright © 1999-2021 by the D Language Foundation