Re: Using pure to create immutable

2011-09-23 Thread Daniel Murphy
Jesse Phillips jessekphillip...@gmail.com wrote in message news:j5gfsa$2d5g$1...@digitalmars.com... Thank you this lets it compile. I think I had that somewhere, but forgot about it. As Steve mentions, it probably should also work for const arguments too. It probably will, eventually. Some

Re: Using pure to create immutable

2011-09-23 Thread Regan Heath
On Thu, 22 Sep 2011 22:18:29 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 14:10 Steven Schveighoffer wrote: No, the parameter types can be const, and can accept mutable arguments. The main point is, the return value has to be proven to be *unique*. The

Using pure to create immutable

2011-09-22 Thread Jesse Phillips
The discussion on Reddit brought to my attention that pure functions can return and assign to an immutable. http://www.reddit.com/r/programming/comments/knn5p/thoughts_on_immutability_in_d/c2lsgek I am trying to modify the example request to make use of this, but have failed.

Re: Using pure to create immutable

2011-09-22 Thread Dmitry Olshansky
On 22.09.2011 22:53, Jesse Phillips wrote: The discussion on Reddit brought to my attention that pure functions can return and assign to an immutable. http://www.reddit.com/r/programming/comments/knn5p/thoughts_on_immutability_in_d/c2lsgek I am trying to modify the example request to make use

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 23:36:40 Dmitry Olshansky wrote: On 22.09.2011 22:53, Jesse Phillips wrote: The discussion on Reddit brought to my attention that pure functions can return and assign to an immutable. http://www.reddit.com/r/programming/comments/knn5p/thoughts_on_immutabil

Re: Using pure to create immutable

2011-09-22 Thread Steven Schveighoffer
On Thu, 22 Sep 2011 15:44:21 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 23:36:40 Dmitry Olshansky wrote: On 22.09.2011 22:53, Jesse Phillips wrote: The discussion on Reddit brought to my attention that pure functions can return and assign to an

Re: Using pure to create immutable

2011-09-22 Thread Steven Schveighoffer
On Thu, 22 Sep 2011 16:09:29 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 22 Sep 2011 15:44:21 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 23:36:40 Dmitry Olshansky wrote: On 22.09.2011 22:53, Jesse Phillips wrote: The discussion

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 16:09:29 Steven Schveighoffer wrote: On Thu, 22 Sep 2011 15:44:21 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 23:36:40 Dmitry Olshansky wrote: On 22.09.2011 22:53, Jesse Phillips wrote: The discussion on Reddit

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 16:11:05 Steven Schveighoffer wrote: On Thu, 22 Sep 2011 16:09:29 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 22 Sep 2011 15:44:21 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 23:36:40 Dmitry

Re: Using pure to create immutable

2011-09-22 Thread Steven Schveighoffer
On Thu, 22 Sep 2011 16:15:20 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 16:09:29 Steven Schveighoffer wrote: Technically, something like this could be cast to immutable: T[] foo(const(T)[] arg) pure Since it can be proven that the result is new

Re: Using pure to create immutable

2011-09-22 Thread Steven Schveighoffer
On Thu, 22 Sep 2011 16:23:12 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 16:11:05 Steven Schveighoffer wrote: On Thu, 22 Sep 2011 16:09:29 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 22 Sep 2011 15:44:21 -0400, Jonathan M Davis

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 13:25 Steven Schveighoffer wrote: On Thu, 22 Sep 2011 16:15:20 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 16:09:29 Steven Schveighoffer wrote: Technically, something like this could be cast to immutable: T[]

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 14:03 Jonathan M Davis wrote: In any case, in order for a function to be able to have its return value implicitly value implicitly cast to immutable, it must pure and all of its arguments must be immutable[...] Ouch! I really must reread my posts more before

Re: Using pure to create immutable

2011-09-22 Thread Jonathan M Davis
On Thursday, September 22, 2011 14:10 Steven Schveighoffer wrote: On Thu, 22 Sep 2011 17:03:08 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: In any case, in order for a function to be able to have its return value implicitly value implicitly cast to immutable, it must pure and all of

Re: Using pure to create immutable

2011-09-22 Thread Jesse Phillips
Dmitry Olshansky Wrote: Maybe: - List!T makeFromArray(T)(immutable T[] array) pure { -- Dmitry Olshansky Thank you this lets it compile. I think I had that somewhere, but forgot about it. As Steve mentions, it probably should also work for const arguments too.

Re: Using pure to create immutable

2011-09-22 Thread bearophile
Jesse Phillips: Thank you this lets it compile. I think I had that somewhere, but forgot about it. As Steve mentions, it probably should also work for const arguments too. If you are convinced of this, then I suggest you to add an enhancement request in Phobos about it. It will make purity