Dynamic Require API - Invocation Arguments

65 views
Skip to first unread message

Kris Kowal

unread,
Jan 26, 2011, 7:55:55 PM1/26/11
to comm...@googlegroups.com
On Wed, Jan 26, 2011 at 2:06 PM, khs4473 <khs...@gmail.com> wrote:
> - Whether the module identifiers should be specified in a variadic
> list or an array:

A.) LOAD("a", "b", "c", function(...) { ... });
B.) LOAD(["a", "b", "c"], function(...) { ... });

Current show of hands. Please copy and update this block in responses.

A.)
B.) Kris Kowal +1, Christoph Dorn +1

Christoph Dorn on B: "This seems cleaner and easier to scan and lends
itself better to dynamic generation."

Kris Kowal

Mikeal Rogers

unread,
Jan 26, 2011, 7:57:39 PM1/26/11
to comm...@googlegroups.com
A.)
B.) Kris Kowal +1, Christoph Dorn +1, Mikeal Rogers +1

James Burke

unread,
Jan 26, 2011, 8:26:12 PM1/26/11
to comm...@googlegroups.com
On Wed, Jan 26, 2011 at 2:55 PM, Kris Kowal <kris....@cixar.com> wrote:
> On Wed, Jan 26, 2011 at 2:06 PM, khs4473 <khs...@gmail.com> wrote:
>> - Whether the module identifiers should be specified in a variadic
>> list or an array:
>
> A.) LOAD("a", "b", "c", function(...) { ... });
> B.) LOAD(["a", "b", "c"], function(...) { ... });

B.) +1 James Burke

Not adding the names, because I already started typing one message
before another came in with someone else's response in another thread,
so probably best to just indicate your preference and tabulate later.

James

Kris Kowal

unread,
Jan 26, 2011, 8:36:42 PM1/26/11
to comm...@googlegroups.com
Merging hands.

A.)
B.) Kris Kowal, Christoph Dorn, Mikeal Rogers, James Burke

khs4473

unread,
Jan 26, 2011, 8:55:38 PM1/26/11
to CommonJS
A)

Reasoning: variadic list benefits newbies at minimal cost to advanced
users.

Kris Kowal

unread,
Jan 26, 2011, 9:08:41 PM1/26/11
to comm...@googlegroups.com
On Wed, Jan 26, 2011 at 5:55 PM, khs4473 <khs...@gmail.com> wrote:
> A)
> Reasoning:  variadic list benefits newbies at minimal cost to advanced
> users.

A.) Kevin H Smith

Tom Robinson

unread,
Jan 27, 2011, 4:18:34 AM1/27/11
to comm...@googlegroups.com
What about a third option: the first argument could be an array, or a string if you want to load a single module.

C) LOAD(<String,Array> ids, function(...) { ... });

Kris Kowal

unread,
Jan 27, 2011, 4:24:09 AM1/27/11
to comm...@googlegroups.com
+1 for single-module shorthand.

A.) LOAD("a", "b", "c", function(...) { ... });
B.) LOAD(["a", "b", "c"], function(...) { ... });

C.) LOAD("a", function (a) { ... });

Hands:

A.) Kevin H Smith
B.) Kris Kowal, Christoph Dorn, Mikeal Rogers, James Burke

B+C.) Tom Robinson, Kris Kowal

Irakli Gozalishvili

unread,
Jan 27, 2011, 9:06:12 AM1/27/11
to comm...@googlegroups.com
+1 B+C

Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/
Address: 29 Rue Saint-Georges, 75009 Paris, France



--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.


Hannes Wallnoefer

unread,
Jan 27, 2011, 9:12:09 AM1/27/11
to comm...@googlegroups.com
A.) LOAD("a", "b", "c", function(...) { ... });
B.) LOAD(["a", "b", "c"], function(...) { ... });
C.) LOAD("a", function (a) { ... });

Hands:

A.) Kevin H Smith
B.) Kris Kowal, Christoph Dorn, Mikeal Rogers, James Burke

B+C.) Tom Robinson, Kris Kowal, Irakli Gozalishvili, Hannes Wallnoefer

2011/1/27 Irakli Gozalishvili <rfo...@gmail.com>:

johnjbarton

unread,
Jan 27, 2011, 11:09:54 AM1/27/11
to CommonJS


On Jan 27, 6:12 am, Hannes Wallnoefer <hann...@gmail.com> wrote:
> A.) LOAD("a", "b", "c", function(...) { ... });
> B.) LOAD(["a", "b", "c"], function(...) { ... });
> C.) LOAD("a", function (a) { ... });
>
> Hands:
>
> A.) Kevin H Smith
> B.) Kris Kowal, Christoph Dorn, Mikeal Rogers, James Burke, John J. Barton

+1

khs4473

unread,
Jan 27, 2011, 11:20:08 AM1/27/11
to CommonJS
I (khs) would accept B+C as an alternative to A.

Kris Kowal

unread,
Jan 27, 2011, 12:11:19 PM1/27/11
to comm...@googlegroups.com
Update:

A.) LOAD("a", "b", "c", function(...) { ... });
B.) LOAD(["a", "b", "c"], function(...) { ... });
C.) LOAD("a", function (a) { ... });

Hands:

A.) Kevin H Smith
B.) Kris Kowal, Christoph Dorn, Mikeal Rogers, James Burke, John J Barton


B+C.) Tom Robinson, Kris Kowal, Irakli Gozalishvili, Hannes

Wallnoefer, Kevin H Smith

Christoph Dorn

unread,
Jan 27, 2011, 12:27:39 PM1/27/11
to comm...@googlegroups.com
Going with B or B+C.

Update:

Hands:

Wallnoefer, Kevin H Smith, Christoph Dorn

James Burke

unread,
Jan 27, 2011, 1:32:59 PM1/27/11
to comm...@googlegroups.com
On Wed, Jan 26, 2011 at 11:18 PM, Tom Robinson <tlrob...@gmail.com> wrote:
> What about a third option: the first argument could be an array, or a string if you want to load a single module.
>
> C) LOAD(<String,Array> ids, function(...) { ... });

I prefer that the API args look similar to any module declaration,
like the define/module.declare variants that allow specifying
dependencies as an array. I like the mental model of "dependencies are
always in an array", which allows for easier human reading of code,
and gives the complete module API (definition and dynamic require)
more consistency.

So I'm still in B).

James

Nathan Rajlich

unread,
Jan 27, 2011, 1:28:44 PM1/27/11
to comm...@googlegroups.com
All 3 versions could be easily supported by just a couple lines of code...

    function(modulesArray, callback) {
      if (!Array.isArray(modulesArray)) {
        callback = arguments[arguments.length-1];
        modulesArray = slice.call(arguments, 0, arguments.length-1);
      }
      // The rest of the module initialization...
    }

No?

Florian Traverse

unread,
Jan 27, 2011, 1:54:00 PM1/27/11
to comm...@googlegroups.com
Again, my syntax should be a

C) REQUIRED_DEP("a").REQUIRED_DEP("b").EVENTUAL_ALIAS("foo").REQUIRED_DEP("b").LOAD(function(...){...})

2011/1/27 Nathan Rajlich <nat...@tootallnate.net>

khs4473

unread,
Jan 28, 2011, 4:02:25 PM1/28/11
to CommonJS
> No?

That's right - in fact, that's what I've got FlyScript doing.


On Jan 27, 1:28 pm, Nathan Rajlich <nat...@tootallnate.net> wrote:
> All 3 versions *could* be easily supported by just a couple lines of code...
> > commonjs+u...@googlegroups.com<commonjs%2Bunsubscribe@googlegroups.c om>
> > .
Reply all
Reply to author
Forward
0 new messages