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

FOR_EACH for many parameters #301

Merged
merged 9 commits into from
May 24, 2021
Merged

Conversation

dprzybyl
Copy link
Collaborator

No description provided.

@dprzybyl dprzybyl linked an issue May 20, 2021 that may be closed by this pull request
@@ -23,3 +23,23 @@ FOR-EACH i IN ['a', 'b'] BEGIN
SHOW $i+'/'+$j
END
END

FOR-EACH [i, j] IN [['a', 'b'], ['c', 'd']] BEGIN
Copy link
Contributor

@mjedraszczyk mjedraszczyk May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ([i, j]) looks like creation of array with 2 elements. It would be simpler by using just FOR i, j IN. Why did you use 2 dimensional array in second part of statement? In this contex it is hard to tell what would be assigned to i and j. Cannot you just stay with flat, one dimensional array? In my opinion syntax like FOR i, j IN ['a', 'b', 'c', 'd'] would be simpler, and better. Users can take advantage of multiline array definitione to organize the data legibly. For example:

DEFINE users [
   # user's email   name     password
    'user@email',  'name',  'p@$$word',
    'user2@email', 'name2', 'p@$$word',
    'user3@email', 'name3', 'p@$$word',
    'usern@email', 'namen', 'p@$$word'] 

FOR-EACH email, name, password IN $users BEGIN
...
END

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one-liner is only an example, you can write it in other ways:

FOR-EACH [i, j] 
IN [
    ['a', 'b'], 
    ['c', 'd']
] 
BEGIN

or

DEFINE tabs [
    ['a', 'b'], 
    ['c', 'd']
] 
FOR-EACH [i, j] 
IN $tabs
BEGIN

now is more readable

@dprzybyl dprzybyl merged commit 14d4667 into master May 24, 2021
@dprzybyl dprzybyl deleted the feature/for-each-for-many-parameters branch May 25, 2021 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FOR_EACH for many parameters
3 participants