Thread overview | |||||
---|---|---|---|---|---|
|
October 25, 2006 Overloading Operator ! | ||||
---|---|---|---|---|
| ||||
I've been working on my own EBNF parser (basically a D version of boost's spirit) but I just realised that you can't overload unary ! Walter, are there any plans to do overload additional operators? The docs state: Future Directions The operators =, !, ., &&, ||, ?:, and a few others will likely never be overloadable. If we're close to 1.0 should this be changed to "will not be overloadable"? Or will some more squeeze in before 1.0? I've already worked around ! with a slightly different syntax (which I think is better than boost's) so I don't need unary !, just more of a general question. |
October 25, 2006 Re: Overloading Operator ! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rob Atkinson | Overloading unary ! for classes is not a good idea because it should always check if the reference is null; however, I believe it should be overloadable for structs. Supporting unary ! for structs can be as simple as using opEquals(bool). This could also allow if(mystruct). I would currently use this feature in my dstring module to mimic D's if(array) (which is pretty much the same thing, a struct with fancy if(array) and if(!array) syntax - so why not give users this power for their [struct] types). |
October 25, 2006 Re: Overloading Operator ! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rob Atkinson | Rob Atkinson wrote: > I've been working on my own EBNF parser (basically a D version of boost's > spirit) but I just realised that you can't overload unary ! I'd really like to get a D implementation of Spirit! > Walter, are there any plans to do overload additional operators? The docs state: > Future Directions > The operators =, !, ., &&, ||, ?:, and a few others will likely never be > overloadable. > > If we're close to 1.0 should this be changed to "will not be overloadable"? > Or will some more squeeze in before 1.0? > > I've already worked around ! with a slightly different syntax (which I think > is better than boost's) so I don't need unary !, just more of a general question. I'd not count on it for now, too many other things on the plate. |
Copyright © 1999-2021 by the D Language Foundation