On Mon, 2012-01-30 at 02:36 -0600, C Anthony Risinger wrote:
> On Mon, Jan 30, 2012 at 1:41 AM, Kees Bos <[email protected]> wrote:
> > On Sun, 2012-01-29 at 19:38 -0600, C Anthony Risinger wrote:
> >> On Sun, Jan 29, 2012 at 3:23 PM, Peter Bittner <[email protected]> 
> >> wrote:
> >> > Just for curiosity's sake:
> >> >
> >> >> $wnd.__pygwt_modController.load($pyjs.appname, [
> >> >> 'lib\pyjamas.ui.Panel.js',
> >> >> 'lib\pyjamas.ui.HTML.js',
> >> >> 'lib\pyjamas.Window.__oldmoz__.js',
> >> >> 'lib\pygwt.__oldmoz__.js',
> >> >> 'lib\pyjamas.Factory.js',
> >> >> 'lib\pyjamas.ui.js',
> >> >> 'lib\pyjamas.ui.InnerHTML.js',
> >> >
> >> > Why do we need dollar signs in JavaScript code? Hmm...
> >>
> >> `$` is not allowed in python identifiers, thus it guarantees no
> >> conflict between the two.  unfortunately it's used to protect JS from
> >> python (python gets the `$`-less version), and remap tables are used
> >> when conflicts arise; i would have done it reverse, where everything
> >> python gets the `$`, and that would eliminate the need for remap
> >> tables (no native JS objects start with $).
> >
> > This is historically. The integration between python code and javascript
> > used to be very tight. I doubt if that's still needed nowadays.
> 
> could you elaborate [slightly]?  do you mean the `$` themselves are
> not needed (eg. because of things like dict keys in a special object,
> vs. raw JS attribute), or the remap tables, or ... ?  doesn't the
> translator automatically detect collisions now?  i know the `$` is
> used all over the place to store temporary JS variables for
> implementation of iteration, boolean/typeof, etc, but i don't know if
> it's strictly necessary.  from a JS() standpoint at least, the
> separation is kinder (personally i like knowing if a var is JS/Python
> namespace just by convention alone).

In the beginning... python code and javascript code where used together,
at least that's what it felt like when I started (somewhere around 0.5).
The idea was that you could access javascript variables from python and
vice verse (and without prefixes or whatsoever). Since python couldn't
have '$' in the variables, these where used in the translator (and a few
other places) to create temporary / 'system' variables that shouldn't
interfere with possible python code. Later on clashes between javascript
python names where fixed by mapping for X to $$X.

I'm not sure, but I think the 'from __javascipt__ import X' is
introduced later. This deprecates the need for equal python/javascript
names. That's for variable/function names. It's different for attribute
and method names. There are javascript (DOM) attributes that are called
from python. If we would have all python attributes/methods have to
start with e.g. '$', all these standard attributes/methods would need an
'$' equivalent. That has it's (dis)advantages (speed/argument checking).


Reply via email to