digitalmars.D - std.algorithm and immutable arrays
- Andrei Alexandrescu (15/15) Jun 09 2010 I'm thinking of the recently discussed problem and it seems that
- Michel Fortin (9/12) Jun 09 2010 This looks good to me.
- BCS (8/13) Jun 09 2010 b.vote++
- Simen kjaeraas (4/7) Jun 10 2010 This absolutely seems sensiblest. Vote++;
- Simen kjaeraas (4/7) Jun 10 2010 This absolutely seems sensiblest. Vote++;
- Steven Schveighoffer (5/8) Jun 10 2010 I think this works well.
- Bruno Medeiros (4/7) Jun 15 2010 tailconst strikes back? :]
I'm thinking of the recently discussed problem and it seems that immutable arrays are an issue not only for find(), but for all functions that need ranges. To fix things I'd need to add code for detecting immutable(T[]) and converting it to immutable(T)[] for _every_ algorithm using ranges out there. That would make things worse from a readability standpoint. So we're looking at a number of options: (a) Leave things as they are. To use std.algorithm with immutable arrays you need to peel off the top-level immutable. (b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible. (c) Bludgeon std.algorithm to work with immutable(T[]). What say you? Andrei
Jun 09 2010
On 2010-06-09 20:41:48 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> said:(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible.This looks good to me. Although I wonder what happens if that range is a class, will you get a rebindable reference to a class? -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 09 2010
Hello Andrei,(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible. What say you?b.vote++ Making that an implicit conversion on any copy should be safe. But would it have any side effects? Also, would that strip it by default or only when the called function demands it?-- ... <IXOYE><
Jun 09 2010
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible.This absolutely seems sensiblest. Vote++; -- Simen
Jun 10 2010
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible.This absolutely seems sensiblest. Vote++; -- Simen
Jun 10 2010
On Wed, 09 Jun 2010 20:41:48 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible.I think this works well. Same goes for const and shared. -Steve
Jun 10 2010
On 10/06/2010 01:41, Andrei Alexandrescu wrote:(b) Promote a change in the compiler to convert immutable(T[]) to immutable(T)[] when passed by value into a function. This is safe and sensible.tailconst strikes back? :] -- Bruno Medeiros - Software Engineer
Jun 15 2010