On Mon, Mar 2, 2009 at 1:32 PM, hasen <hasan.alj...@gmail.com> wrote:
> How about, adding a new attribute to functions: `pure` > > pure real sin( real x ) { ... } > > and design the rest around this concept. > > The compiler must make sure that this function is really pure: > - native types must be passed by value, not by reference > - doesn't accept pointers > - <insert some condition for objects and arrays> > > If these requirements aren't met, the compiler will spit some error message > "in function <F>: doing <X> voilates the `pure` attribute" Umm.. maybe you didn't read far enough, but D2 already has pure functions. http://www.digitalmars.com/d/2.0/function.html > Also, make `string` a builtin type that's immutable (like python), and > discourage the use of char[] as a type for strings, (unless used to > implement a special string class). > > The need for a special string type also stems from the fact that char[a..b] > slices bytes, not characters! Again, 'string' is defined as an alias to invariant(char)[]. It's an immutable builtin type. It still has the problem of slicing/indexing on bytes rather than characters, but the alias is already there, Phobos already uses it extensively, and if it were changed to a struct in the future it would probably cause few to no problems.