Chip Salzenberg wrote:
According to Brent 'Dax' Royal-Gordon:

Chip Salzenberg <[EMAIL PROTECTED]> wrote:

  parrot_alias(a, 'b',             # dest: Python is unified, no need for a category 
here
               a, 'b', 'scalar')   # src:  Perl is not unified, so source category is 
required

It seems to me that a much easier way to handle this would be to mangle Perl variables to something that most languages *can* access:

$foo=s_foo
@foo=a_foo

For those languages that support native Hashes, it should be relatively simple to give the user direct access to a Namespace PMC as if it would be a native Hash, (all it needs is a Hash-vtable, maybe a Namespace PMC should be just a Hash)...


#Python_on_Parrot Library function using inline PASM
baz = Parrot_GetNameSpace("Perl::Foo::Baz)

# Get the scalar
s_foo = baz["$foo"]

# Get the array
a_foo = baz["@foo"]

print Parrot_GetNameSpace("Perl::Foo::Baz")["$foo"];

For splitted namespaces (variable/function) we will then have to agree on a per language basis how to distinguish them. For example a language in which function calls have paranthesis can add them to the name to distinguish a functions from a variable.

namespace["foo"]   # variable
namespace["foo()"] # function

Simple yet intuitive. Other example: Lisp

lisp["foo"]  # variable
lisp["(foo)] # function

My point is that a variable was represented as a string in the language
is was originally written, to access it from other languages, we should use an interface that allows us to index it via just that string.


All the other logic needed to import stuff should be left to a module for that given language. It knows better wich types have to be converted which functions need wrappers, etc ...

just had to give my 2 cents on namespaces :)
Thomas Seiler

Reply via email to