Please explain this unexpected syntax

Posted on 2009-02-09
Last Modified: 2013-12-10
I have encountered some TCL code (well, Jacl code really), that has the statements shown below.

I understand that #1 creates a new java Object, having a value of 1.  So far, so good.

What I don't understand is the 2nd statement.  I'm used to seeing

set variableName value

So what is this doing?

set 0 value

and why is this after a dereferenced variable?

If you could explain this, and provide equivalent Jython, it would be greatly appreciated.

set params [java::new {java.lang.Object[]} {1}]

$params set 0 [java::field class]

Open in new window

Question by:HonorGod
    LVL 41

    Author Comment

    Here's the "equivalent" Jython code...

    import as sch
    params = [ sch.BeanTaskInfo ];    # class reference
    sigs   = [ 'java.lang.Class' ];   # "Signature" identifying "params" type

    Open in new window

    LVL 92

    Assisted Solution

    its setting an element in the array isn't it

    LVL 41

    Author Comment

    According to the Tcl documentation, one would use the "array" keyword to define an array.

    So, I'm still confused.
    array set colorcount {
        red   1
        green 5
        blue  4
        white 9

    Open in new window

    LVL 15

    Accepted Solution

    It'a special JACL syntax to manipulate Java arrays:


    In this example, we see how to allocate an array of java.lang.String objects. This example also demonstrates Java array object commands and their equivalent Java statements, see the javaArrayObj section for more information.
    # This is equivalent to the Java statement.
    # String[] arr = new String[2];
    set arr [java::new {String[]} {2}]

    # Set the values of the array elements.
    # This is equivalent to the following Java statements.
    # arr[0] = "Hello";
    # arr[1] = "World";
    $arr set 0 "Hello"
    $arr set 1 "World"
    LVL 41

    Author Closing Comment

    mish33 was completely correct, so gets most of the points.
    objects was first, and partially correct, so get some of the points.

    Thanks again folks!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    changeXy challenge 13 41
    countAbc challenge 9 35
    Arduino EDI - Programming language 3 34
    White board coding practice 3 35
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now