D - [bug]
- Dr.Dizel <Dr.Dizel_member pathlink.com> Jan 23 2004
- imr1984 <imr1984_member pathlink.com> Jan 23 2004
- Dr.Dizel <Dr.Dizel_member pathlink.com> Jan 23 2004
- Andrew Edwards <edwardsac spamfreeusa.com> Jan 23 2004
- Ilya Minkov <minkov cs.tum.edu> Jan 23 2004
- J C Calvarese <jcc7 cox.net> Jan 23 2004
Here if I change string "_vec.length = _vec.length + 1;" to "++_vec.length;" it
reports me a bug. :-\ Am I have a bug or dmd. :)
class vebu
{
uint _last = 0;
ubyte[4096][] _vec;
this() { _vec.length = 1;}
public:
void add(ubyte _byte)
{
if (_last >= _vec[0].length) { _vec.length = _vec.length + 1; _last = 0;}
_vec[_vec.length - 1][_last] = _byte; ++_last;
}
void add(ubyte[] _p1) { foreach(ubyte F; _p1) add(F);}
uint length() { return (_vec.length - 1) * 4096 + _last;}
//...
}
Jan 23 2004
what you are trying to do isnt supported, although i wish it was In article <buqr9u$2hpd$1 digitaldaemon.com>, Dr.Dizel says...Here if I change string "_vec.length = _vec.length + 1;" to "++_vec.length;" it reports me a bug. :-\ Am I have a bug or dmd. :) class vebu { uint _last = 0; ubyte[4096][] _vec; this() { _vec.length = 1;} public: void add(ubyte _byte) { if (_last >= _vec[0].length) { _vec.length = _vec.length + 1; _last = 0;} _vec[_vec.length - 1][_last] = _byte; ++_last; } void add(ubyte[] _p1) { foreach(ubyte F; _p1) add(F);} uint length() { return (_vec.length - 1) * 4096 + _last;} //... }
Jan 23 2004
In article <bur463$30a3$1 digitaldaemon.com>, imr1984 says...what you are trying to do isnt supported, although i wish it was
Jan 23 2004
Dr.Dizel wrote:In article <bur463$30a3$1 digitaldaemon.com>, imr1984 says...what you are trying to do isnt supported, although i wish it was
But... it works in this case :-\
_vec.length = _vec.length + 1; that is authorized in D. What is not authorized is the incrementation or decrementation of properties using ++ or --. so you cannot type ++_vec.length _vec.length++ in hopes of obtaining the same outcome as above (it is not supported)! Andrew
Jan 23 2004
Andrew Edwards wrote:so you cannot type ++_vec.length _vec.length++
However, what is the purpose of this? If the purpose is to add a new element el, simply do: vec ~= el; -eye
Jan 23 2004
Andrew Edwards wrote:Dr.Dizel wrote:In article <bur463$30a3$1 digitaldaemon.com>, imr1984 says...what you are trying to do isnt supported, although i wish it was
But... it works in this case :-\
_vec.length = _vec.length + 1; that is authorized in D. What is not authorized is the incrementation or decrementation of properties using ++ or --. so you cannot type ++_vec.length _vec.length++ in hopes of obtaining the same outcome as above (it is not supported)! Andrew
I'd still like to be able to do vec.length++, but the compiler deliberately prohibits this: "Note: Properties currently cannot be the lvalue of an op=, ++, or -- operator." http://www.digitalmars.com/d/property.html (bottom of page) I think the reason might be the one that Sean Palmer suggested, "Am I correct in saying that the problem is that we can't know if postfix++ happens before or after the assignment, which depends on the ++ executing before the assignment, or it'll store into invalid memory?" D/12869 Other theories: D/12707 D/12858 -- Justin http://jcc_7.tripod.com/d/
Jan 23 2004









Ilya Minkov <minkov cs.tum.edu> 