Hi Stas,
On Wed, Feb 5, 2014 at 5:29 PM, Stas Malyshev <[email protected]>wrote:
> > I meant the form of the code, not assert().
> > JavaScript uses callbacks extensively and users are used to it.
> > PHP users are also getting used to it since the introduction of closure.
>
> But I mean assert(). Javascript implementations have assert() - Chrome
> has it, Firefox has it, NodeJS has it. It does not work like you
> propose. Doesn't it make you question your assertion that Javascript
> users really need this?
I think it's nice to have as it does not use variable scope/name space.
Code related to assert() is better to hide it's existence as much as
possible. IMO.
JavaScript implementations have different APIs. Node.js has closer API.
assert.throws(
function() {
throw new Error("Wrong value");
},
Error
);
while we may have
assert(
function() {
// Some check here
return FALSE;
},
'Error'
);
I would use at least, since I don't want to assert() related code to use
variable scope nor namespace.
Regards,
--
Yasuo Ohgaki
[email protected]