March 15, 2013 Re: C++ guys hate static_if? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | 15-Mar-2013 06:43, deadalnix пишет: > On Thursday, 14 March 2013 at 23:52:59 UTC, Nick Sabalausky wrote: >> On Thu, 14 Mar 2013 17:54:52 -0400 >> Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: >>> [snip] >> That implicitly does the equivalent of ".save" on a mere InputRange >> *twice*. The result, of course, is completely dependent on the input >> range in question. > > Passing range by value is completely undefined, which is IMO a big weak > spot of ranges. What can be done in the mean time is stating somewhere prominent this: Given InputRanges a & b: 1. a = b; //now 'a' can only be *either* an alias of 'b' or 'a' is a copy of 'b' 2. a = move(b); //now a is the only copy (the only alias ;)) 3. a = b.save(); //now a is guaranteed to be a shallow copy By copy here it's implied that range preserves iteration state. The underlying values may be changed elsewhere. There could be some argument to make 1 always do 3 and trim it to 2 rules. But ehm, sorry, classes as ranges can't do that so we are stuck. If I had to choose I'd drop the current OOP support of D in favor of simplifying things (only half-joking) :) -- Dmitry Olshansky |
March 15, 2013 Re: C++ guys hate static_if? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | 15-Mar-2013 15:27, Dmitry Olshansky пишет: > 15-Mar-2013 06:43, deadalnix пишет: >> On Thursday, 14 March 2013 at 23:52:59 UTC, Nick Sabalausky wrote: >>> On Thu, 14 Mar 2013 17:54:52 -0400 >>> Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: >>>> > [snip] >>> That implicitly does the equivalent of ".save" on a mere InputRange >>> *twice*. The result, of course, is completely dependent on the input >>> range in question. >> >> Passing range by value is completely undefined, which is IMO a big weak >> spot of ranges. > > What can be done in the mean time is stating somewhere prominent this: > > Given InputRanges a & b: Forward obviously. > > 1. a = b; //now 'a' can only be *either* an alias of 'b' or 'a' is a > copy of 'b' > 2. a = move(b); //now a is the only copy (the only alias ;)) > 3. a = b.save(); //now a is guaranteed to be a shallow copy > > By copy here it's implied that range preserves iteration state. The > underlying values may be changed elsewhere. > > There could be some argument to make 1 always do 3 and trim it to 2 > rules. But ehm, sorry, classes as ranges can't do that so we are stuck. > > If I had to choose I'd drop the current OOP support of D in favor of > simplifying things (only half-joking) :) > -- Dmitry Olshansky |
March 15, 2013 Re: C++ guys hate static_if? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 3/14/2013 1:27 PM, Walter Bright wrote: > We can do a lot, lot better before we need something better than -cov. A proposal to improve the use of -cov: http://d.puremagic.com/issues/show_bug.cgi?id=9726 |
March 20, 2013 Re: C++ guys hate static_if? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hans Uhlig | On 2013-03-12, 23:49, Hans Uhlig wrote: > On 3/9/2013 10:10 AM, deadalnix wrote: >> On Saturday, 9 March 2013 at 17:51:31 UTC, Ali Çehreli wrote: >>> On 03/09/2013 03:15 AM, Artur Skawina wrote: >>> >>> > - static-if not creating scopes /is/ confusing, but what >>> would be a better >>> > alternative? >>> >>> I am surprised that << and >> are never mentioned: >>> >>> static_if >> >>> void foo(); >>> << >>> >>> Problem solved. ;) >>> >>> Ali >> >> static if(condition) « >> void foo(); >> » >> >> Let's do it with style ;) > > So now I am going to need a unicode keyboard or a massive list of unicode code points. Or we could make the language latex-aware, and use \guillemotleft and \guillemotright. That would also solve the problem of operators ∃, √, ⊂, ∩, ∙, ⨯, and the like. I kid, of course. But it might be worth having a look at Fortress for their representational and editable forms, as well as the wealth of overloadable operators. -- Simen |
Copyright © 1999-2021 by the D Language Foundation