Jeff Clites <[EMAIL PROTECTED]> wrote: > First off, Perl5 doesn't describe itself that way. The Camel states, > "Note that we can use the same name for $days, @days, and %days without > Perl getting confused."
While that's fine for Perl it doesn't help, if you want to access one distinct "days" from Python: import days from Perl.foo # which one? > So it's true that $foo and @foo are different items, but that can be > stated as, "the scalar 'foo' and the array 'foo' are different items, > with the same names". That does only work, if the context provides enough information, which one of the "foo"s should be used. That information isn't present always. > without the name decoration. For example, in Common Lisp, this: > (foo foo) > means, "call the function foo, and pass the variable foo as an > argument". Ok, then a hyptothetical CL translator has to take care of this. The "foo" variable is probably kind of a lexical, the function "foo" is accessible. If both "foo"s are global, the same problem as above exists. >> If you want to use a perl5 module from Python which has both $foo and >> @foo exported, we can just pitch a fit. > We should be able to handle accessing either, if Python provides a > syntax for doing so. "If" ... which isn't the case. >> And: we can't attach hints to the namespace lookup because you just >> don't know, if Python wants the scalar "foo" or the array "foo". There >> is exactly one "foo" object that Python can use, that's it. > That's not accurate, and it's not a hint, it's a demand--the programmer > should know exactly which one he wants The programmer might know it, but Python has no means to express the difference. > a = lookupPerlScalar("foo"); There isn't a possibility for the Python translator to generate that kind of code in the general case. Did you read the bytecode snippet? It's just: LOAD_NAME "foo" nothing else. > I think we have issues going from Perl to Python as well, in other > cases. Things such as arrays/hashes/strings should come across as > references--so I'd say that in Python you access [EMAIL PROTECTED] rather than @foo > directly, because assignment in Python doesn't copy. I don't think so. Python's assignment is pure name binding. In Python you access that thing that is in name slot "foo". That has nothing to do with references, which Python doesn't have anyway. If you have in Python foo = bar then that's in bytecode: LOAD_NAME "bar" STORE_NAME "foo" Now both these name slots have the same item. But modifying e.g. "bar" doesn't effect "foo", it's not a reference that is common to these name slots. The real troubles arise from different issues. Given a PerlString "s" handled over to Python. Now Python code looks like this: s += "x" or print s % (2,3) If "s" were a Python string, the first would concatenate, the second is a sprintf-like interpolation. So what is the result, when "s" is a PerlString? > JEff leo