Re: D 1.076 Alpha for Windows 64 bits, works with VS 2010
On 06/10/12 20:38, Walter Bright wrote: On 9/30/2012 9:35 PM, Andrej Mitrovic wrote: On 10/1/12, Walter Bright newshou...@digitalmars.com wrote: Also, consider that in C++ you can throw any type, such as an int. There is no credible way to make this work reasonably in D, as exceptions are all derived from Exception. Is that a bug or a feature? :) It's a feature, and I'm not joking. What is the compelling use case for throwing an int? How could that possibly fit into some encapsulation model? What if library A throws an int, and library B does? Now you catch an int - which did it come from? You've got no clue. It's indistinguishable from garbage. Just imagine how much fun could be had, if D let you throw sqrt(17.0) + 37.919i.
Re: Remus
As promised, a little description of Remus. :) Not Null references: I chose this syntax: int b = a; because I like it in C++. This syntax is recognized by Remus and is converted to: Ref!(int) b = a; If you must give a reference to a function or other things like that, you can write: [code] Foo obj = new Foo(); some_function(@obj) [/code] instead of [code] Foo obj = new Foo(); { Foo robj = obj; some_function(robj); } [/code] Namespaces: You can declare a namespace this way: [code] namespace io { void print() { writeln(foo); } } [/code] you _cannot_ use it without explicit use statement (will maybe change). So you must write [code]use io;[/code] to use _all_ methods from io, or, like import, [code]use io : print[/code] or [code]use io : write = print;[/code] use statements are converted to one or more alias' and namespaces to (mixin) templates. not null safe invocation: If you have an object which can be null, you can write: obj?.print(); the print method is only called, if obj is not null. It works even with more than one '?': obj?.getOtherObj?.print(); but then you have to take care of some special weakneses: Until now you can not write obj?.getOtherObj()?.print() because the parent's aren't recognized as valid identifiers for '?'. So you must use properties or this workaround: [code] Foo otherObj = obj?.getOtherObj(); // otherObj is null if obj is null otherObj.print(); [/code] Furthermore you cannot use '?' in the middle or end, or with breaks. So these are valid: a?.b.c and this a?.b?.c but these a.b?.c and a?.b.c?.d not. I described some more examples, do's and don't's on my website. Stack Instances: There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope. My next version will contain the elvis operator: [code] Foo obj = otherObj.get() ?: null; if otherObj.get() is _not_ null, it will assign to obj, otherwise obj will be assigned with null. [/code] And maybe cast's with 'as'. But my main interests are to fix the bugs and weakneses. That's it. Sorry for the few words, but I'm a bit busy right now. If you have questions or suggesstions you can write it here, I will read it every evening.
Re: Remus
Namespace: Not Null references: I chose this syntax: int b = a; because I like it in C++. This syntax is recognized by Remus and is converted to: Ref!(int) b = a; If you must give a reference to a function or other things like that, you can write: [code] Foo obj = new Foo(); some_function(@obj) [/code] instead of [code] Foo obj = new Foo(); { Foo robj = obj; some_function(robj); } This seems far from being well designed not-nullable pointers/class references :-( [/code] Namespaces: You can declare a namespace this way: [code] namespace io { void print() { writeln(foo); } } [/code] you _cannot_ use it without explicit use statement (will maybe change). So you must write [code]use io;[/code] to use _all_ methods from io, or, like import, [code]use io : print[/code] or [code]use io : write = print;[/code] use statements are converted to one or more alias' and namespaces to (mixin) templates. But what are they useful for? Stack Instances: There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope. scope was removed for certain reasons, are those reasons not valid for local? Bye, bearophile
Re: Remus
On Tuesday, 9 October 2012 at 19:34:01 UTC, Namespace wrote: Stack Instances: There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope. What's the difference between this and std.typecons.scoped, except for alignment and syntax?
Re: Remus
This seems far from being well designed not-nullable pointers/class references :-( And why not? In my test cases, they fulfilled their task / purpose very well. And you ask for what namespaces are usefull? Aren't you miss them? I do, and so I implement them. You can already write namespaces in D, but you must use a (mixin) template (so you have these ugly parents) and for using you have to write: alias tpl_nspace!().print print or directly: tpl_nspace!().print. And that's ugly (because of '!()') and annoying IMO. For what local is good for and whats the differences between my version and scoped from dmd I will tell later, but as you can see: you have to write: local Foo f = new Foo(); what is more intuitive as Scoped! Foo f = scoped!Foo(); IMO.