On Wed, 31 Dec 2014 09:40:17 +0000 Tobias Pankrath via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> > another "cosmetic issue" that bugs me alot. > > > > p.s. and with pointers it's easy to write something like this: > > > > auto parseNumber (string s, bool* error=null); > > > > yes, i know about exceptions... which blocks `@nogc`. not yummy. > > You could preallocate the exception or use an out parameter. i can do alot of things here... and something is not possible with `ref`. this will not work: auto parseNumber (string s, ref bool error=null); ther is no way to point ref to dummy temp by default, sure, i can write two functions: auto parseNumber (string s, out bool error); auto parseNumber (string s) { bool dummy; return parseNumber(s, dummy); } see how it's turning to messy code with copypasta? the thing is that `ref` params can't be ommited by specifying `null` here, and there is no `dummy` placeholder for refs. the same is true for `out`s, of course. and preallocating exception is loosing valuable information about the place where that exception was thrown. or i have to write a module which emulates `new` for exception objects and don't forget to check if it is "D exception" or "my exception" in `catch` block, so i can manually release my exceptions. ah, i'd better go with my ugly pointers.
signature.asc
Description: PGP signature