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

implement seq in EO with the help of dataized #3078

Closed
yegor256 opened this issue Apr 10, 2024 · 19 comments
Closed

implement seq in EO with the help of dataized #3078

yegor256 opened this issue Apr 10, 2024 · 19 comments

Comments

@yegor256
Copy link
Member

I believe, it should be possible, with the help of recursion

@maxonfjvipon
Copy link
Member

maxonfjvipon commented Apr 10, 2024

I think we will need try object here because it has finally attribute which just dataizes object and forgets about it

@l3r8yJ
Copy link
Contributor

l3r8yJ commented Apr 13, 2024

@yegor256 @maxonfjvipon @volodya-lombrozo is this issue free? can I take this one?

@maxonfjvipon
Copy link
Member

@l3r8yJ thanks for your desire to help. Of course you can try, but it would be kind of dirty implementation which abuses the design of try. So I'm not sure we really need it now in such way.
@yegor256 WDYT?

@l3r8yJ
Copy link
Contributor

l3r8yJ commented Apr 13, 2024

@maxonfjvipon then maybe you know an another issue I can help with?

@yegor256
Copy link
Member Author

@maxonfjvipon I would wait a bit with this ticket

@Chamber6821
Copy link
Contributor

Chamber6821 commented Jun 9, 2024

[steps] > seq
  loop 0 > @

  [index] > loop
    if. > @
      and.
        index.lt steps.length
        (dataized (steps.at index)).size.ge 0 # any convertion to true
      loop (index.plus 1)
      true

Variants of convertion to true

  1. (dataized (steps.at index)).size.ge 0
  2. (dataized (steps.at index)).as-bool.if true true

@Chamber6821
Copy link
Contributor

To deny remove dataization object must have flag that dataization of object has side effects. I think about this mechanism as portal from declarative EO to platform, for example any call of C API has side effect

@Chamber6821
Copy link
Contributor

Chamber6821 commented Jun 9, 2024

It is works!

# The test Application with very important comment XXXXXXXXXXXXXXXXXX.
[args] > app
  my-seq > @
    *
      QQ.io.stdout "1\n"
      QQ.io.stdout "2\n"
      QQ.io.stdout "3\n"
      QQ.io.stdout "4\n"

  [steps] > my-seq
    loop 0 > @

    [index] > loop
      if. > @
        and.
          index.lt steps.length
          steps.at index
        ^.loop
          index.plus 1
        true

@maxonfjvipon
Copy link
Member

@Chamber6821 looks pretty good. But the logic of seq assumes that it dataizes all the steps except the last one, which is just returned without dataization. You may see it here (ind < items.length - 1)

@Chamber6821
Copy link
Contributor

@maxonfjvipon fixed

# The test Application with very important comment XXXXXXXXXXXXXXXXXX.
[args] > app
  my-seq > @
    *
      QQ.io.stdout "1\n"
      false
      QQ.io.stdout "2\n"
      false
      QQ.io.stdout "3\n"
      false
      QQ.io.stdout "4\n"
      false

  [steps] > my-seq
    loop 0 > @

    [index] > loop
      if. > @
        and.
          index.lt (steps.length.minus 1)
          or.
            (dataized (steps.at index)).as-bool
            true
        ^.loop
          index.plus 1
        steps.at index

@maxonfjvipon
Copy link
Member

@Chamber6821 much better, one more thing: if steps is empty - seq should return true

@Chamber6821
Copy link
Contributor

Chamber6821 commented Jun 9, 2024

@maxonfjvipon

# The test Application with very important comment XXXXXXXXXXXXXXXXXX.
[args] > app
  my-seq > @
    *
      QQ.io.stdout "1\n"
      false
      QQ.io.stdout "2\n"
      false
      QQ.io.stdout "3\n"
      false
      QQ.io.stdout "4\n"
      false

  [steps] > my-seq
    if. > @
      steps.length.eq 0
      true
      loop 0

    [index] > loop
      if. > @
        and.
          index.lt (steps.length.minus 1)
          or.
            (dataized (steps.at index)).as-bool
            true
        ^.loop
          index.plus 1
        steps.at index

@Chamber6821
Copy link
Contributor

I will create PR

@maxonfjvipon
Copy link
Member

@Chamber6821 yeah, you can try

@maxonfjvipon
Copy link
Member

@yegor256 let's make a new release with tag 0.38.4

@yegor256
Copy link
Member Author

@rultor release, tag is 0.38.4

@rultor
Copy link
Contributor

rultor commented Jun 13, 2024

@rultor release, tag is 0.38.4

@yegor256 OK, I will release it now. Please check the progress here

@rultor
Copy link
Contributor

rultor commented Jun 13, 2024

@rultor release, tag is 0.38.4

@yegor256 Done! FYI, the full log is here (took me 15min)

@maxonfjvipon
Copy link
Member

@yegor256 I'm closing it since it's implemented

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

No branches or pull requests

5 participants