documenting /src/foundation/gclib_misc.js

0 views
Skip to first unread message

agent marmorkuchen

unread,
Mar 11, 2009, 12:12:16 PM3/11/09
to groundcrew-vie...@googlegroups.com
hello there...

looking at documenting /src/foundation/gclib_misc.js:

- $method: why is this function prefixed with a $-sign? should that
imply that it deals with metaprogramming? in that case it seems
inconsistent when looking at to_f which also deals with
metaprogramming but follows a Ruby naming convention (if i am not
mistaken). but then it seems unused anyway.

- $method: another Javascript question:
the function uses obj[method](x); if method is 'foobar' for example,
are these two lines equivalent?
obj['foobar'](x);
obj.foobar(x);
so you can always use hash keys instead of the dot-notation to call
functions in objects in Javascript?

- to_f: i'd like to suggest two one-line additions:
first line: if (!x) return null;
last line: return null; (not sure if that is redundant in Javascript,
but it clarifies the programmer's intention)

- what does rebuzz do? although it seems unused.

- tag: it seems that a given attribute 'cls' overrides the classes
specified in the tag's name. could the code be changed to this?

if (attrs.cls) {
attrs['class'] = attrs.cls;
delete attrs.cls;
} else if (name.contains('.')) {
var words = name.split('.');
name = words[0];
attrs['class'] = words.slice(1).join(' ');
}

on the other hand, 'cls' does not seem to be used at all (atm), so we
might actually drop support for it?

- json_eval: it seems unused, but i assume it is supposedly taking a
JSON expression as argument and evaluates it?

- index_item(s)_by: they seem unused and i am not sure if index_item_by
is actually doing what it is supposed to do. remove them?

bye,
marmorkuchen
--
_ ascii ribbon campaign .oOo. GCSd-s:+aC++ULB+++W++M+PS+++Y+
( )
X Trust your technolust!
/ \

Joe Edelman

unread,
Mar 11, 2009, 12:42:06 PM3/11/09
to groundcrew-vie...@googlegroups.com
Sebastian,

I'm actually going to be cleaning this stuff up some today.

But to answer your javascript question, foo[bar] and foo.bar are
basically identical, except that foo.bar() sets 'this' to foo and
foo[bar]() does not.

--Joe

--
J.E. -- http://nxhx.org -- 413.250.8007
Reply all
Reply to author
Forward
0 new messages