Interesting idea. Rolf. Are you aware of Jmol's recently added .. notation?

x = {"a": {"1": ["x", "y", "z"], "2": ["I", "II"]}}

print x
print x..a
print x..a..1
print x..a..1..2

Does that satisfy your needs? It is only for regular arrays or associative
arrays with simple keys. You can't do this:

print x.."testing here"

for that you still need

print x["testing here"]

(Just as in JavaScript.)

Personally, I would not like to try to build Perl-like syntax into Jmol.
Overall it is very unlike C++ or Java or JavaScript, and I've tried to keep
as close to those as possible. In Perl I believe the -> notation is for *array
references:*

    my @array = (1, 2, 3, 'four');
    my $reference = \@array;
    print $reference->[0];

not actual array names, right? You can't do this:

    my @array = (1, 2, 3, 'four');
    print $array->[0];

right? So I would prefer not to add that confusion to the mix.

Ambiguity of ranges: It's not that there is any ambiguity. I assure you
that is not the case. But Jmol's notation is a bit idiosyncratic, I admit.
The fact that the first model in a file was always "1" led me to develop 1
as the base for array elements. Was it a good choice? Maybe not. But that's
what we have. And the fact that we often want the last model suggested then
that [0] could mean "the last" rather than "the first". And so we have
ranges such as a[3][-3]. It's not ambiguous. But it is multipurpose. So, as
you point out, for associative arrays, a[1][1] is not a range. (What would
a "range" in an associative array mean, after all.) It must  be that "1" is
a key in a, and that key refers to either another associative array with a
"1" key or a serial array with at least one element. (Maybe that's what you
mean by "ambiguous".  That's true.)

Hope that helps.

Bob
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to