Re: static try?

2011-11-02 Thread Don
On 31.10.2011 02:21, Mehrdad wrote: I've written this piece of code a fair number of times: static if (is(typeof(foo( { foo(); } else { bar(); } When the expression inside the condition (i.e. the call to foo()) gets complicated, you get lots of code duplication and things become harder to

Re: static try?

2011-11-02 Thread Don
that string mixins are seriously overused in D. IMnsHO they should only be used as a method of last resort. For every case I've seen where there is a alternative to a string mixin, the alternative was cleaner. If people don't like the static try/catch, how about: static try/else? Probably worth

Re: static try?

2011-11-02 Thread Mehrdad
duplication and things become harder to read. IMHO the only problem is the is(typeof()) syntax. Otherwise I don't see how this has any more code duplication than: if( foo(lots_of_parameters) ) foo(lots_of_parameters); else bar(); Huh? sorry but I'm confused as how that's related to static try

Re: static try?

2011-11-02 Thread deadalnix
to foo()) gets complicated, you get lots of code duplication and things become harder to read. So I'm thinking, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean and immensely readable

Re: static try?

2011-11-02 Thread Don
as how that's related to static try/catch... The only benefit you'd get from static try/catch is a small reduction in code duplication, in one specific idiom. I'm arguing that the code duplication is no worse in this case than in anything other case in the language. I'm not seeing why

Re: static try?

2011-11-02 Thread deadalnix
{ ... } Please no! I've thought for years that string mixins are seriously overused in D. IMnsHO they should only be used as a method of last resort. For every case I've seen where there is a alternative to a string mixin, the alternative was cleaner. If people don't like the static try/catch, how about

Re: static try?

2011-11-02 Thread bcs
{ ... } Please no! I've thought for years that string mixins are seriously overused in D. IMnsHO they should only be used as a method of last resort. For every case I've seen where there is a alternative to a string mixin, the alternative was cleaner. If people don't like the static try/catch, how about

Re: static try?

2011-11-01 Thread Robert Jacques
lots of code duplication and things become harder to read. So I'm thinking, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean

Re: static try?

2011-11-01 Thread dennis luehring
become harder to read. So I'm thinking, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean and immensely readable

Re: static try?

2011-11-01 Thread Vladimir Panteleev
On Tue, 01 Nov 2011 18:33:56 +0200, dennis luehring dl.so...@gmx.net wrote: introduces an compiletime scope - what would the following code mean? debug, version, static if don't create scopes. -- Best regards, Vladimirmailto:vladi...@thecybershadow.net

Re: static try?

2011-11-01 Thread kenji hara
of times:     static if (is(typeof(foo( { foo(); }     else { bar(); } When the expression inside the condition (i.e. the call to foo()) gets complicated, you get lots of code duplication and things become harder to read. So I'm thinking, why not just introduce a 'static try'? Something like

Re: static try?

2011-11-01 Thread dennis luehring
the try{...} static try { -- foo1(); foo2(); foo3(); -- } catch { bar(); } im missing a description of what should happen if any of the foos fails to compile? is then the catch part used in compilation? the idea is too near to the syntax

Re: static try?

2011-11-01 Thread bcs
are seriously overused in D. IMnsHO they should only be used as a method of last resort. For every case I've seen where there is a alternative to a string mixin, the alternative was cleaner. If people don't like the static try/catch, how about: static try/else? Kenji Hara 2011/10/31 Mehrdadwfunct

Re: static try?

2011-10-31 Thread deadalnix
to read. So I'm thinking, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean and immensely readable improvement IMO, and it doesn't introduce any new keywords or any breaking

Re: static try?

2011-10-31 Thread Mehrdad
of code duplication and things become harder to read. So I'm thinking, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean and immensely readable improvement IMO, and it doesn't

static try?

2011-10-30 Thread Mehrdad
, why not just introduce a 'static try'? Something like: static try { foo(); } catch // (string ex) // perhaps let them know what the error is? { bar(); } It's a clean and immensely readable improvement IMO, and it doesn't introduce any new keywords or any

Re: Checking function callability in D1 (aka static try-catch)

2008-12-07 Thread Christian Kamm
This topic came up (again) fairly recently, and a solution was proposed, but I found a case where that solution doesn't work. The objective is to do a static check to see if something is callable with particular argument types, and if so call it. The proposed solution was to use '.init'

Re: Checking function callability in D1 (aka static try-catch)

2008-12-07 Thread Bill Baxter
On Sun, Dec 7, 2008 at 7:08 PM, Christian Kamm [EMAIL PROTECTED] wrote: This topic came up (again) fairly recently, and a solution was proposed, but I found a case where that solution doesn't work. The objective is to do a static check to see if something is callable with particular argument