Hi,
I dont know anything about the performance issues, but understand that require 
establish the object in memory once even referred to many times in a ddoc.
From a programmers view I would vote for "this", meaning that if it is a branch 
of the ddoc.
I remember that when I discovered that I could refer to my set of templates in 
a ddoc with this.templates[template] it was a big win.
As I know this today it can only work with refering to strings and that require 
must be used to parse function code into objects.
If what you are proposing is that loading the ddoc automatically parses code, I 
think this is a useful simplification.

johs



> On 2. des. 2015, at 21.03, Alexander Shorin <kxe...@gmail.com> wrote:
> 
> On Wed, Dec 2, 2015 at 9:53 PM, ermouth <ermo...@gmail.com> wrote:
>>> 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.
> 
> Hm...good point. Such JS feature ruins this use-case. Thanks!
> 
> So we have two candidates left:
> - require()
> - this
> 
> And seems like this is simpler both for users, developers and for
> implementation, since there is no need to hack require or inject
> special CommonJS lib in order to make things work.
> 
> --
> ,,,^..^,,,

Reply via email to