Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ordering arrays #11

Open
daimor opened this issue Dec 14, 2015 · 10 comments
Open

ordering arrays #11

daimor opened this issue Dec 14, 2015 · 10 comments

Comments

@daimor
Copy link

daimor commented Dec 14, 2015

instead of with getting next index in the end of loop

set ind=$order(array(""))
for {
    quit:ind=""

    /// some code here
    set ind=$order(array(ind))
}

should be

set ind=""
for {
    set ind=$order(array(ind))
    quit:ind=""

    /// some code here
}
@adaptun
Copy link
Contributor

adaptun commented Dec 14, 2015

IMHO, it's more like best practices, not code style guidelines.

@tsafin
Copy link
Contributor

tsafin commented Dec 14, 2015

Agreed with Sasha @adaptun here - it's more suitable to future "Best Practices" Wiki. Same as with #10

@isc-solon
Copy link
Contributor

Both loops above are fine. I wouldn't recommend one more than the other. The first style gives you the ability to quit before entering the loop, but there are 2 $order functions. The second style only has one $order function, but you always enter the loop.

@daimor
Copy link
Author

daimor commented Dec 23, 2015

In any way you entering the loop, and in second style, you also can quit before $order, but I don't see any way why it should be needed. One main idea, is, in first variant, you can't use continue, because you should first get a next value by $order, and after that you code will be unreadable. And in "right" variant, you can go to next value in any place of your loop.

set ind=""
for {
    set ind=$order(array(ind))
    quit:ind=""
    quit:ind="end"
    continue:$get(array(ind,"skip"))

    /// some code here
}

@eduard93
Copy link
Contributor

We can start filling BESTPRACTICES.md as well

@tsafin
Copy link
Contributor

tsafin commented Dec 23, 2015

@eduard93 we could start witth MD file, but I still believe that Wiki pages would be easier to maintain and navigate for this kind of content.

@eduard93
Copy link
Contributor

@tsafin GitHub project wiki eg. MDX2JSON wiki is just another repo with md files, so I see no point in maintaining two repos with text files instead of one.
default

@daimor
Copy link
Author

daimor commented Dec 23, 2015

Or instead of wiki possible to use Read the docs, one of examples here

@tsafin tsafin added the Wiki label Dec 23, 2015
@tsafin
Copy link
Contributor

tsafin commented Dec 23, 2015

Although their markup might be the same, but from usabiliy point of view Wiki is much more convenient to use (especially for well structured hierarchy). IMVHO

@tsafin
Copy link
Contributor

tsafin commented Dec 23, 2015

@daimor but Read the docs looks nice. But this is external dependency, which might eventually
disappear.

P.S.
If time permits we need to play with this tool though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants