http://d.puremagic.com/issues/show_bug.cgi?id=7135
--- Comment #8 from Kenji Hara <[email protected]> 2012-01-01 05:56:47 PST --- (In reply to comment #7) > One more thing - the example in the book reads: > > obj.addMethod("sayHello", > Variant(Dynamic, Variant[]...) { > writeln("Hello, world!"); > return Variant(); > }); > > That doesn't work. The compilable version reads: > > obj.addMethod("sayHello", > delegate Variant(Dynamic, Variant[]...) { > writeln("Hello, world!"); > return Variant(); > }); > > Can we arrange things such that the "delegate" or "function" keywords aren't > require in the literal definition? >From past, omission of delegate keyword + specification of return type has been wrong syntax. So Variant(Dynamic, Varinat[]...) { ... } couldn't compile. And recent commit https://github.com/D-Programming-Language/dmd/commit/c50eb5f5726a65efa1224ff0f0fd60acbb6e3027 has been disallowed optional parameter names, because of parameter type inference. >From these matters, current TDPL code never become valid. ---- Today, following literal notations has been allowed with current dmd. delegate Variant(Dynamic self, Variant[] args...) {...} delegate (Dynamic self, Variant[] args...) {...} (Dynamic self, Variant[] args...) {...} ---- Note: Unfortunately, current dmd does not support parameter type inference + type-safe variadisc like follows. //delegate (self, args...) {...} //(self, args...) {...} Because args could have three kind of infer targets. T[N] args... // T is the element type of args T[] args... // T is the element type of args T args... // T is class type, and args is translated to new T(args) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
