D - [bug]
- Dr.Dizel (17/17) Jan 23 2004 Here if I change string "_vec.length = _vec.length + 1;" to "++_vec.leng...
- imr1984 (2/19) Jan 23 2004
- Dr.Dizel (2/3) Jan 23 2004 But... it works in this case :-\
- Andrew Edwards (10/18) Jan 23 2004 I assume you mean here:
- Ilya Minkov (5/9) Jan 23 2004 However, what is the purpose of this? If the purpose is to add a new
- J C Calvarese (17/42) Jan 23 2004 I'd still like to be able to do vec.length++, but the compiler
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 wasBut... it works in this case :-\
Jan 23 2004
Dr.Dizel wrote:In article <bur463$30a3$1 digitaldaemon.com>, imr1984 says...I assume you mean here: _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)! Andrewwhat you are trying to do isnt supported, although i wish it wasBut... it works in this case :-\
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: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?" http://www.digitalmars.com/drn-bin/wwwnews?D/12869 Other theories: http://www.digitalmars.com/drn-bin/wwwnews?D/12707 http://www.digitalmars.com/drn-bin/wwwnews?D/12858 -- Justin http://jcc_7.tripod.com/d/In article <bur463$30a3$1 digitaldaemon.com>, imr1984 says...I assume you mean here: _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)! Andrewwhat you are trying to do isnt supported, although i wish it wasBut... it works in this case :-\
Jan 23 2004