Hello Brad: Half of Vass's argument is cogent: const in implies a copy while const ref does not.
It's a language design choice whether the values from a tuple may be used to initialize the elements of an array. As long as there in an array literal syntax, accepting a tuple literal in the same context seems optional. At such time as a move-constructor is provided, it would be possible to efficiently "steal" the initial value of an array from an array literal, whereas (it seems to me) an element-by-element copy would be required if the initializer is a tuple. If we have to choose one or the other, then supporting the array literal and deprecating the tuple literal is the clear choice. As a feature however, being able to initialize an array from a tuple is "pretty cool" in spite of its apparent inefficiency. It would be too bad to give that up unless it is demonstrably hard to support. THH ________________________________________ From: Brad Chamberlain [[email protected]] Sent: Thursday, February 13, 2014 10:03 PM To: Vasily Litvinov Cc: Chapel Sourceforge Developers List Subject: Re: [Chapel-developers] Retire tuple-to-array assignment? I'm not convinced by that argument, nor the analogy. Move constructors plus def-use analysis should support the ability to steal such initializing array values. -Brad ________________________________________ From: Vassily Litvinov [[email protected]] Sent: Thursday, February 13, 2014 7:25 PM To: Brad Chamberlain Cc: Chapel Sourceforge Developers List Subject: Re: [Chapel-developers] Retire tuple-to-array assignment? One reason to keep such assignment is for performance. At least for as long as we do not optimize away the extra array creation in "var A = [1.2, 3.4, 5.6];" Pretty much the same argument as why we want to pass records by const ref instead of const in. :) Vass On 02/13/2014 05:45 PM, Brad Chamberlain wrote: > > Hi Chapel Developers -- > > A bug I ran into today made me realize the following for the first time: > > > Back in the dark ages when we didn't have array literals, we used tuple > literals as the means of initializing arrays, primarily because we had no > other recourse. Thus, you'd write: > > var A: [1..3] real = (1.2, 3.4, 5.6); > > > Now that we're in the middle ages, a savvy Chapel programmer would write > this as: > > var A: [1..3] real = [1.2, 3.4, 5.6]; > > or even: > > var A = [1.2, 3.4, 5.6]; > > > But somehow it had escaped my attention that we never disabled the "assign > tuple to array" case. I'm thinking that we probably should, but wanted to > see if there were any opposing viewpoints. > > Simultaneously with expressing this opinion, I'm checking to see whether > there are any cases in the test suite that suggest preserving the > capability, or whether they should just be rewritten to use array > literals. All the ones I've seen so far are the latter cases. > > Thanks, > -Brad > > PS -- Sadly, this realization didn't actually help with my bug... > > ------------------------------------------------------------------------------ > Android apps run on BlackBerry 10 > Introducing the new BlackBerry 10.2.1 Runtime for Android apps. > Now with support for Jelly Bean, Bluetooth, Mapview and more. > Get your Android app in front of a whole new audience. Start now. > http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk > _______________________________________________ > Chapel-developers mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/chapel-developers > ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ Chapel-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-developers ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ Chapel-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-developers
