digitalmars.D - Provide immutable attribute for first-class citizens and namespaces?
- Daniel Fitzpatrick (16/16) Apr 13 2012 A few languages out there provide immutability by default. I'm
- deadalnix (3/19) Apr 14 2012 « immutable: » can't do the trick ?
- Daniel Fitzpatrick (13/16) Apr 14 2012 Do you mean to extend the immutable keyword instead of adding an
- Daniel Fitzpatrick (5/21) Apr 14 2012 Okay...yes.
- Daniel Fitzpatrick (1/4) Apr 14 2012
A few languages out there provide immutability by default. I'm on board with D not providing it by default, but would it be useful or worth the effort to add an immutable attribute to first class citizens and namespaces eg // All members & fn returns immutable by default in each case immutable module my.ns; immutable class foo { .. } immutable struct bar { .. } Additionally, module blah; const import std.algorithm; // All return refs/vals & public members from std.algorithm treated as immutable within blah I hesitated to post this since I haven't done much with D, so I hope I'm not insulting anyone (I have great respect for you all - you were very helpful when I was trying to learn the language). No idea how hard this is. Thoughts?
Apr 13 2012
Le 14/04/2012 08:56, Daniel Fitzpatrick a écrit :A few languages out there provide immutability by default. I'm on board with D not providing it by default, but would it be useful or worth the effort to add an immutable attribute to first class citizens and namespaces eg // All members & fn returns immutable by default in each case immutable module my.ns; immutable class foo { .. } immutable struct bar { .. } Additionally, module blah; const import std.algorithm; // All return refs/vals & public members from std.algorithm treated as immutable within blah I hesitated to post this since I haven't done much with D, so I hope I'm not insulting anyone (I have great respect for you all - you were very helpful when I was trying to learn the language). No idea how hard this is. Thoughts?« immutable: » can't do the trick ? BTW, this proposal is a bit problematic without a mutable keyword.
Apr 14 2012
« immutable: » can't do the trick ?Do you mean to extend the immutable keyword instead of adding an attribute, or that the immutable keyword, as is, is enough? I'm fine with the former. The latter is problematic. Think turnabout - would you enjoy having to mark all of your variables 'mutable' when you wanted them like that? As it is, that would add a ton of declarations to the standard library.BTW, this proposal is a bit problematic without a mutable keyword.I thought about this: I wouldn't be interested in it. I would be interested in a library which provided containers with different semantics for atomic mutation. What Clojure provides is pretty spot on: http://clojure.org/refs http://clojure.org/agents http://clojure.org/atoms
Apr 14 2012
On Saturday, 14 April 2012 at 17:50:01 UTC, Daniel Fitzpatrick wrote:Okay...yes. I hadn't thought about using attributes in that way. Maybe this is a nonissue. :)« immutable: » can't do the trick ?Do you mean to extend the immutable keyword instead of adding an attribute, or that the immutable keyword, as is, is enough? I'm fine with the former. The latter is problematic. Think turnabout - would you enjoy having to mark all of your variables 'mutable' when you wanted them like that? As it is, that would add a ton of declarations to the standard library.BTW, this proposal is a bit problematic without a mutable keyword.I thought about this: I wouldn't be interested in it. I would be interested in a library which provided containers with different semantics for atomic mutation. What Clojure provides is pretty spot on: http://clojure.org/refs http://clojure.org/agents http://clojure.org/atoms
Apr 14 2012
http://dlang.org/attribute.html is what I'm referencing.Okay...yes. I hadn't thought about using attributes in that way. Maybe this is a nonissue. :)
Apr 14 2012