The following code does not work:
Object o
Object someObjects[] ={object(1),object(2)}
for o in someObjects do {}
Neither does this one
Object o
Array someObjects = create(2,1)
put(someObjects,object(1),0,1)
put(someObjects,object(2),1,1)
for o in someObjects do {}
delete someObjects
Only Skip list do it:
Object o
Skip someObjects = create
put(someObjects,object(1),0)
put(someObjects,object(2),1)
for o in someObjects do {}
delete someObjects
Of course, when you have an array, either some C like array [] or some Array, you can still iterate based on the index, however it would be more convenient to have the short hand of directly iterating without using indexation, like in Java.
Vincent.
SystemAdmin - Fri Feb 18 02:59:15 EST 2011 |
|
Re: Iterating on an array SystemAdmin - Fri Feb 18 05:02:24 EST 2011
DXL != Java :-)
Your skip list example won't work either, because the skip for loop iterates over the data, not over the key. Re-worked example
Object o = current Object
Skip someObjects = create
put(someObjects, 0, o)
put(someObjects,1, next(o))
for o in someObjects do
{
print identifier(o)
}
delete someObjects
|
|
Re: Iterating on an array SystemAdmin - Fri Feb 18 06:31:13 EST 2011
Thanks for the feedback,
Actually that was my understanding also that for will iterate on data, but as I am rather new to DXL, I was confused by this that put has a different order of arguments with Array and with Skip.
For Array data is given first and then position (index of row and column in array), while for Skip this is the other way round, the key (which is a kind of position argument) is given before the data.
This is not very consistent. I am sure that there is a good reason for that kind of convention, certainly the documentation could be improved by highlighting why.
|
|
Re: Iterating on an array SystemAdmin - Fri Feb 18 06:31:17 EST 2011
Thanks for the feedback,
Actually that was my understanding also that for will iterate on data, but as I am rather new to DXL, I was confused by this that put has a different order of arguments with Array and with Skip.
For Array data is given first and then position (index of row and column in array), while for Skip this is the other way round, the key (which is a kind of position argument) is given before the data.
This is not very consistent. I am sure that there is a good reason for that kind of convention, certainly the documentation could be improved by highlighting why.
|
|
Re: Iterating on an array Mathias Mamsch - Fri Feb 18 06:48:38 EST 2011
One dimensional arrays cannot be iterated using for ... in do. You need to iterate over the indices:
Object o
Object someObjects[] ={object(1),object(2)}
int i; for i in 0:(sizeof someObjects)-1 do {
o = someObjects[i]
}
Regards,Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Iterating on an array Mathias Mamsch - Fri Feb 18 06:51:18 EST 2011 SystemAdmin - Fri Feb 18 06:31:17 EST 2011
Thanks for the feedback,
Actually that was my understanding also that for will iterate on data, but as I am rather new to DXL, I was confused by this that put has a different order of arguments with Array and with Skip.
For Array data is given first and then position (index of row and column in array), while for Skip this is the other way round, the key (which is a kind of position argument) is given before the data.
This is not very consistent. I am sure that there is a good reason for that kind of convention, certainly the documentation could be improved by highlighting why.
VincentBelaïche(RDF) said
... I am sure that there is a good reason for that kind of convention ...
sorry but: HAHAHA! If for every DXL weirdness there is a good reason, there must be a lot of untapped wisdom on this planet :-) :-) Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: Iterating on an array llandale - Fri Feb 18 09:34:21 EST 2011 SystemAdmin - Fri Feb 18 06:31:17 EST 2011
Thanks for the feedback,
Actually that was my understanding also that for will iterate on data, but as I am rather new to DXL, I was confused by this that put has a different order of arguments with Array and with Skip.
For Array data is given first and then position (index of row and column in array), while for Skip this is the other way round, the key (which is a kind of position argument) is given before the data.
This is not very consistent. I am sure that there is a good reason for that kind of convention, certainly the documentation could be improved by highlighting why.
"Good Reason"? DXL started out pretty humbly and has expanded over the years. More likely one person implemented Arrays and another implemented Skip lists. Is there a "good reason" one dude decided to put 10 hot dogs in a pack and another to put 8 rolls in a pack? Is there a "good reason" God made folks inclined to build statues of their heroes, and also invented Pigeons?
"certainly the documentation could be improved by highlighting why"? Its rare for user documentation to explain why a decision was made the way it was. This documentation could be better by simply explaining "what" and "how" things work, not just "what" the commands do.
OK, there is indeed a "good reason" for the 10/8 hot dog situation, but lets not ruin my clever retort with the actual facts, thank you very much.
|
|
Re: Iterating on an array SystemAdmin - Fri Feb 18 10:36:07 EST 2011 llandale - Fri Feb 18 09:34:21 EST 2011
"Good Reason"? DXL started out pretty humbly and has expanded over the years. More likely one person implemented Arrays and another implemented Skip lists. Is there a "good reason" one dude decided to put 10 hot dogs in a pack and another to put 8 rolls in a pack? Is there a "good reason" God made folks inclined to build statues of their heroes, and also invented Pigeons?
"certainly the documentation could be improved by highlighting why"? Its rare for user documentation to explain why a decision was made the way it was. This documentation could be better by simply explaining "what" and "how" things work, not just "what" the commands do.
OK, there is indeed a "good reason" for the 10/8 hot dog situation, but lets not ruin my clever retort with the actual facts, thank you very much.
Well,
I can imagine that maybe God has invented pigeons to do some additional decoration on statues so that they are not sinfully taken for idols, but I have no idea on the hot-dog/roll ratio 10/8 ratio ;-P
Anyhow, I just wanted to say that when there is some inconsistency or some weird thing, it should be highlighted by the reference manual, there should some convention decided at some point of time, and whatever is outside the convention highlighted as weird. This is what is done with Upper case of first letter, the manual says things like "Arrays are pretty old in DXL, and this is why they are named like this".
Well, anyhow, I could not find any coding rules for DXL, so I cannot say either whether type should begin or not with an upper case letter.
Vincent.
|
|
Re: Iterating on an array llandale - Fri Feb 18 11:18:30 EST 2011 SystemAdmin - Fri Feb 18 10:36:07 EST 2011
Well,
I can imagine that maybe God has invented pigeons to do some additional decoration on statues so that they are not sinfully taken for idols, but I have no idea on the hot-dog/roll ratio 10/8 ratio ;-P
Anyhow, I just wanted to say that when there is some inconsistency or some weird thing, it should be highlighted by the reference manual, there should some convention decided at some point of time, and whatever is outside the convention highlighted as weird. This is what is done with Upper case of first letter, the manual says things like "Arrays are pretty old in DXL, and this is why they are named like this".
Well, anyhow, I could not find any coding rules for DXL, so I cannot say either whether type should begin or not with an upper case letter.
Vincent.
I do not agree that there should be some fixed standard suggesting that ALL "put" commands start with the data and then have the location. I do agree that it would be better if there were. A personal example is that I wrote a "fIsSubString" and a "fIsPrefix" functions that have reversed fields; and I never remember if its "fIsSubString(string InString, SubString)" or "fIsSubString(string SubString, InString)". Used them 1000 times but still cannot remember.
And even if there indeed "should" be, its not realistic here since DXL started out so small on a questionable product with little understanding it would blossom as it has.
Yes, Utah towns are very neatly laid out with a "Main" and a "Front" streets in a strict coordinate system because they exist according to a plan, but few eastern towns are cleverly laid out, there was one road, later then added another, then connected up the 3rd town, then someone needed a parallel road for deliveries, ...
You cannot impose clever town layouts on existing towns ... without first destroying them.
|
|
Re: Iterating on an array SystemAdmin - Tue Feb 22 04:44:36 EST 2011
Hello,
Please note that I never wrote that placing data first and then index would be the legitimate convention for put. Actually, what I think is that what is legitimate is just the other way round:
in C you write arrayindex = new_element, to the order of argument is 1st array, 2nd index and 3rd new_element. In VB this is the same order, in Lisp also: (aset ARRAY IDX NEWELT).
Generally speaking, I think that a nice order of arguments is something like this:
-
1st = object to be manipulated (changed)
-
2nd = aspect, index, location, field identifier, tag, etc... implied in defining how the manipulation has to be carried out
-
3rd = new data that is what is changed by the manipulation
So --- in my opinion --- the documentation would be improved if for description of ``put data in array'' there was some indication that the order of arguments is this strange way for some historical reason.
BR,
Vincent.
|
|
Re: Iterating on an array llandale - Tue Feb 22 12:09:10 EST 2011 SystemAdmin - Tue Feb 22 04:44:36 EST 2011
Hello,
Please note that I never wrote that placing data first and then index would be the legitimate convention for put. Actually, what I think is that what is legitimate is just the other way round:
in C you write arrayindex = new_element, to the order of argument is 1st array, 2nd index and 3rd new_element. In VB this is the same order, in Lisp also: (aset ARRAY IDX NEWELT).
Generally speaking, I think that a nice order of arguments is something like this:
-
1st = object to be manipulated (changed)
-
2nd = aspect, index, location, field identifier, tag, etc... implied in defining how the manipulation has to be carried out
-
3rd = new data that is what is changed by the manipulation
So --- in my opinion --- the documentation would be improved if for description of ``put data in array'' there was some indication that the order of arguments is this strange way for some historical reason.
BR,
Vincent.
Not suggesting that your Variable-Location-Data ordering is wrong; but I am suggesting that having them "admit" its "wrong" and providing a historical reason for it in the DXL manual is hopeless. That would be completely out of character with the rest of the manual, and there are far more important things the manual "should" do, such as explaining how things work much better instead of just providing turse sentances of how each function behaves, when the input is correct; such as providing all the perms they intend to keep; such as fixing the documentation bugs taht have existed for years; bla bla bla.
|
|