Skip to content

another issue:

Forums Forums SIMPOL Programming another issue:

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28
    Jim Locker
    Member

    a statement like this will always fail, even when the referenced array contents are indeed identical: if array1[“VAL1”] == array2[1,ii] and array1[“VAL2”] == array2[2,ii] and array1[“VAL3”] == array2[3,ii] else end if The above statement will ALWAYS take the else branch. If rewritten like this: testval1 = array1[“VAL1”] : testval2 = array2[1,ii] if testval1 == testval2 testval1 = array1[“VAL2”] : testval2 = array2[2,ii] if testval1 == testval2 testval1 = array1[“VAL3”] : testval2 = array2[3,ii] if testval1 == testval2 end if end if end if it will evaluate correctly.

    #1675
    Michael
    Keymaster

    Jim wrote:
    > a statement like this will always fail, even when the referenced
    > array contents are indeed identical:
    >
    > if array1["VAL1"] == array2[1,ii] and array1["VAL2"] == array2[2,ii]
    > and array1["VAL3"] == array2[3,ii]
    >
    > else
    >
    > end if
    >
    > The above statement will ALWAYS take the else branch.
    >
    > If rewritten like this:
    >
    > testval1 = array1["VAL1"] : testval2 = array2[1,ii] if testval1 ==
    > testval2 testval1 = array1["VAL2"] : testval2 = array2[2,ii] if
    > testval1 == testval2 testval1 = array1["VAL3"] : testval2 =
    > array2[3,ii] if testval1 == testval2
    >
    > end if end if end if
    >
    > it will evaluate correctly.
    >

    Again, a small reproducible would be good here. I have occasionally seen
    this sort of behavior, but I invariably discover something about my data
    upon closer inspection.

    Ciao, Neil

    #1824
    Jim Locker
    Member

    Neil Robinson wrote:

    > Jim wrote:
    >> a statement like this will always fail, even when the referenced
    >> array contents are indeed identical:
    >>
    >> if array1["VAL1"] == array2[1,ii] and array1["VAL2"] == array2[2,ii]
    >> and array1["VAL3"] == array2[3,ii]
    >>
    >> else
    >>
    >> end if
    >>
    >> The above statement will ALWAYS take the else branch.
    >>
    >> If rewritten like this:
    >>
    >> testval1 = array1["VAL1"] : testval2 = array2[1,ii] if testval1 ==
    >> testval2 testval1 = array1["VAL2"] : testval2 = array2[2,ii] if
    >> testval1 == testval2 testval1 = array1["VAL3"] : testval2 =
    >> array2[3,ii] if testval1 == testval2
    >>
    >> end if end if end if
    >>
    >> it will evaluate correctly.
    >>

    > Again, a small reproducible would be good here. I have occasionally seen
    > this sort of behavior, but I invariably discover something about my data
    > upon closer inspection.

    > Ciao, Neil

    Finding that one took me awhile, and I analyzed that data to a fare thee
    well before rewriting the code; there are NO data issues.

    However on this one I'll pass; setting up a demo example would take a fair
    amount of time, and the issue really isn't *that* important; I'll just
    know to avoid the construction that fails, and I'll also know to look for
    that problem.

    There are a number of unexpected subtleties in how arrays work, and I am
    inclined to call these subtleties bugs because they lead to
    inconsistencies in how things work. I am using them for indirection and
    for hashing, and for many of those things that I would use data structures
    and pointers for in C. However, the actual passing of the contents or a
    proper reference to the contents is not totally reliable, as this case
    indicates. I am learning that often I am safest passing the array member
    contents to a temporary variable and using the temporary variable.

    I would prefer to not have to do this, but needs must.

    This is the same basic issue that came up with my "object not found"
    post.; contents of an array (or the array reference) were not passed in
    the expected fashion.

    #1436
    Michael
    Keymaster

    Jim wrote:
    > Finding that one took me awhile, and I analyzed that data to a fare
    > thee well before rewriting the code; there are NO data issues.
    >
    > However on this one I'll pass; setting up a demo example would take a
    > fair amount of time, and the issue really isn't *that* important;
    > I'll just know to avoid the construction that fails, and I'll also
    > know to look for that problem.
    >
    > There are a number of unexpected subtleties in how arrays work, and I
    > am inclined to call these subtleties bugs because they lead to
    > inconsistencies in how things work. I am using them for indirection
    > and for hashing, and for many of those things that I would use data
    > structures and pointers for in C. However, the actual passing of the
    > contents or a proper reference to the contents is not totally
    > reliable, as this case indicates. I am learning that often I am
    > safest passing the array member contents to a temporary variable and
    > using the temporary variable.

    I would suggest, if you have any sort of complex data, createa type to
    match it, and store the type in the array. Then everything should work
    as expected.

    > I would prefer to not have to do this, but needs must.
    >
    >
    > This is the same basic issue that came up with my "object not found"
    > post.; contents of an array (or the array reference) were not passed
    > in the expected fashion.

    Arrays in SIMPOL are not arrays of a given type, and as such, they work
    in slightly different ways. Array elements that contain a value are the
    only case that I am aware of where the element cannot be treated as an
    object. That is because the array is the object, and this is just a
    value in the object. If you want the content of the array to act like
    objects, assign them as object references, using =@, not =.

    Ciao, Neil

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.