Re: RE: RFC: expectations/assertions

From: Date: Wed, 05 Feb 2014 08:47:16 +0000
Subject: Re: RE: RFC: expectations/assertions
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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]


Thread (44 messages)

« previous php.internals (#72251) next »