array cast should be supported corrected

BCS ao at pathlink.com
Fri Aug 8 10:44:43 PDT 2008


Reply to Steven,

> "BCS" <ao at pathlink.com> wrote in message
> news:55391cb3300e68cac5e93619c98c at news.digitalmars.com...
> 
>> Reply to Bill,
>> 
>>> On Thu, Aug 7, 2008 at 6:06 AM, BCS <ao at pathlink.com> wrote:
>>> 
>>>> Reply to Frank,
>>>> 
>>>>> However. What is better in a template arraycast with o(n) or a
>>>>> cast?
>>>>> The programmer always needs to know what the concequences are.
>>>>> With
>>>>> this argumentation the string concatenation ~ should also be
>>>>> banned
>>>>> from
>>>>> the language, because hidden heap allocation has always unbound
>>>>> execution
>>>>> time.
>>>> Array cat's /always/ do a O(?) allocation and a O(n+m) copy.
>>>> 
>>> Not true for ~=.  Sometimes allocates sometimes doesn't.  You'll
>>> have to come up with a better argument than that. :-)
>>> 
>> http://www.digitalmars.com/d/1.0/arrays.html
>> "Concatenation always creates a copy of its operands"
>> http://www.digitalmars.com/d/1.0/expression.html
>> ""
>> Assignment operator expressions, such as:  a op= b
>> are semantically equivalent to:  a = a op b
>> ""
> I once thought as you do.  However, there is a conflicting statement
> later in that page:
> 
> http://www.digitalmars.com/d/1.0/arrays.html#resize
> 
> Although it says that it applies to the ~ and ~= operator, in reality
> it only applies to the ~= operator, I think that is an error in the
> spec.
> 

ok, new version: "Array cat's are /always/ suposed to do a O(?) allocation 
and a O(n+m) copy."





More information about the Digitalmars-d mailing list