[nodejs] Re: enable/disable assertion

2012-03-05 Thread JeanHuguesRobert
On 29 fév, 11:27, Jann Horn wrote: > And in coffee, you can even use 'fn?()' for that. :P Cool! As a result: assert? xxx ... is problably the best way today to remove asserts in production mode when using CoffeeScript : set assert to null. Idem for trace?() -- Job Board: http://jobs.nodejs.or

[nodejs] Re: enable/disable assertion

2012-03-05 Thread JeanHuguesRobert
On 5 mar, 02:26, Marcel Laverdet wrote: > > de&&bug( msg) is much faster when traces are disabled > > Is this a true statement? "much faster" than debug( msg) of course ;) When traces are disabled, the right side of the && operator is not evaluated ; as a result the call to some "debug( msg)" fu

Re: [nodejs] Re: enable/disable assertion

2012-03-04 Thread Marcel Laverdet
> de&&bug( msg) is much faster when traces are disabled Is this a true statement? On Wed, Feb 29, 2012 at 7:36 AM, JeanHuguesRobert < jeanhuguesrob...@gmail.com> wrote: > On 29 fév, 00:33, Phoscur wrote: > > How is this better than: > > function debug(msg) { > > if (DEBUG_ON) { > >

[nodejs] Re: enable/disable assertion

2012-02-29 Thread JeanHuguesRobert
On 29 fév, 00:33, Phoscur wrote: > How is this better than: > function debug(msg) { >     if (DEBUG_ON) { >         console.log(msg); >     }} > > ? de&&bug( msg) is much faster when traces are disabled. Idem with de&&mand() vs assert(). -- Job Board: http://jobs.nodejs.org/ Posting guidelines:

Re: [nodejs] Re: enable/disable assertion

2012-02-29 Thread Jann Horn
And in coffee, you can even use 'fn?()' for that. :P Am 29.02.2012 08:10 schrieb "Bruno Jouhier" : I use something like: // top of file: var trace = require('appConfig').getTrace(module); // returns logging function or null // anywhere in the file trace && trace(some_message); getTrace can ret

[nodejs] Re: enable/disable assertion

2012-02-28 Thread Bruno Jouhier
I use something like: // top of file: var trace = require('appConfig').getTrace(module); // returns logging function or null // anywhere in the file trace && trace(some_message); getTrace can return console.log but may also return a function that logs to file. On Feb 29, 12:46 am, Diogo Resende

Re: [nodejs] Re: enable/disable assertion

2012-02-28 Thread Diogo Resende
On Wed, 29 Feb 2012 00:33:32 +0100, Phoscur wrote: How is this better than: function debug(msg) { if (DEBUG_ON) { console.log(msg); } } ? The complex logic in msg is processed (in some way) and debug is called. For the same behavior you need to do: function debug() { if (DEBU

Re: [nodejs] Re: enable/disable assertion

2012-02-28 Thread Phoscur
How is this better than: function debug(msg) { if (DEBUG_ON) { console.log(msg); } } ? Am 28.02.2012 23:55, schrieb JeanHuguesRobert: > de = false // true when debugging > de&&mand( cond ) // ie "demand" instead of "assert" > de&&bug( msg) // ie "debug" to output trace msg > > On 27

[nodejs] Re: enable/disable assertion

2012-02-28 Thread JeanHuguesRobert
de = false // true when debugging de&&mand( cond ) // ie "demand" instead of "assert" de&&bug( msg) // ie "debug" to output trace msg On 27 fév, 16:30, Tim Caswell wrote: > That's clever, I like that.  Not sure if I'll use it, but I'll keep the > technique in mind. Thanks! See also http://virtre

Re: [nodejs] Re: enable/disable assertion

2012-02-27 Thread Tim Caswell
That's clever, I like that. Not sure if I'll use it, but I'll keep the technique in mind. On Sun, Feb 26, 2012 at 4:30 AM, JeanHuguesRobert < jeanhuguesrob...@gmail.com> wrote: > De&&mand( something) // ie "Demand" instead of "Assert" > > That's a convention I use to solve your issue. Instead of

[nodejs] Re: enable/disable assertion

2012-02-26 Thread JeanHuguesRobert
De&&mand( something) // ie "Demand" instead of "Assert" That's a convention I use to solve your issue. Instead of commenting out the assertions, I simply sets global "De" variable to false. Note: works for debug trace messages too, using De&&bug( msg) On 26 fév, 10:02, sungchan lee wrote: > H