> It is not possible to check how many arguments functions accepts?

It is, `var fn=function(x,y){};fn.length ==> 2`. Although, you not
necesserily write js function with all args. For example, I can define
update (doc), without req obj if I don‘t need it. Gist below uses only
first arg of 4 in validate_doc_update.

> How this._* will be better than global context?

First, we have global context clean. Second, we do not have to change args
length for existing functions, so we can in many cases just find/replace to
refactore.

I thought a little, and if main reason is security, we better write
validate_doc_update, that parses ddocs and checks if functions use
inappropriate globals or, for example, eval. Validation of this kind is
simple, see here working example
https://gist.github.com/ermouth/953691b6b62c9cab4ff6.

ermouth

2015-12-02 19:17 GMT+03:00 Alexander Shorin <[email protected]>:

> On Wed, Dec 2, 2015 at 6:44 PM, ermouth <[email protected]> wrote:
> > Ain‘t it all too stressful?
> >
> > Approach will make _all_ existing code broken, that will, in turn,
> > effectively deny upgrade for most of users.
>
> Deprecate != remove. Both approaches may co-exist for some time till
> we find a way how to gracefully upgrade the code during yet another BC
> release. The drawback of such upgrade will be all views rebuild,
> suddenly.
>
> > Think old and new approaches better co-exist during several subversions.
> > Note, that co-existanse makes passing ctx via 1st arg impossible.
>
> It is not possible to check how many arguments functions accepts? I
> thought about this way to deal with this problem.
>
> > As for me, I‘d prefer to have emit and co as `this` childs. Like
> > this._emit, this._send, this._getRow and so on. Since properties with
> > leading _ can not exist in ddoc, referenced by `this`, we can extend
> `this`
> > free.
> >
> > Actually, we must have several shallow copies of ddoc, each extended with
> > own set of underscored methods. Each calll to QS function performed using
> > .apply with and appropriate shallow copy.
>
> How this._* will be better than global context? Just curious.
>
> --
> ,,,^..^,,,
>

Reply via email to