I've been reading through the blog post at
https://blogs-pyjeon.rhcloud.com/?p=302

and hence researching some of the complaints there and had a questions
I tried compiling the following piece of code
cat test1.py 
def hello(i):
    i=i*2
    return i
print hello(1)

Which gave the following
sarvi-mac:tmp sarvi$ ../bin/pyjscompile test1.py 
/* start module: test1 */
$pyjs['loaded_modules']['test1'] = function (__mod_name__) {
if($pyjs['loaded_modules']['test1']['__was_initialized__']) return 
$pyjs['loaded_modules']['test1'];
var $m = $pyjs['loaded_modules']['test1'];
$m['__repr__'] = function() { return '<module: test1>'; };
$m['__was_initialized__'] = true;
if ((__mod_name__ === null) || (typeof __mod_name__ == 'undefined')) 
__mod_name__ = 'test1';
$m['__name__'] = __mod_name__;


$m['hello'] = function(i) {
var $mul2,$mul1;
i = (typeof ($mul1=i)==typeof ($mul2=2) && typeof $mul1=='number'?
$mul1*$mul2:
$p['op_mul']($mul1,$mul2));
return i;
};
$m['hello']['__name__'] = 'hello';

$m['hello']['__bind_type__'] = 0;
$m['hello']['__args__'] = [null,null,['i']];
$p['printFunc']([$m['hello'](1)], 1);
return this;
}; /* end test1 */


/* end module: test1 */


Question 1:
     The simple i=i*2 seems to have a complex translation. Can't it just be 
i=i*2 in java script and handle the error when it happens?

Question 2:
   The whole idea of using dictionaries to store functions seems 
inefficient for access. Is there an alternative approach using say
prototype.bin() or other approaches to define and access these functions 
that people have tried?

Sarvi

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyjs-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to