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

#598 Add file IO flush function #619

Merged
merged 2 commits into from
Jul 5, 2024
Merged

Conversation

bhavik-goplani
Copy link
Contributor

Solves #598

I had a little difficulty testing. This runs without bugs but doesn't write to the file when I run my bend program. Am I missing something here? I also built both bend and hvm from the main branch.

def main:
  file = IO/FS/open("file.txt", "w+")
  data = "Hello, World!"
  write = IO/FS/write(file, data)
  flush = IO/FS/flush(file)
  close = IO/FS/close(file)
  return 0

@developedby
Copy link
Member

Have you run you program using bend run, bend run-c or bend run-cu?

Also, you have to rebase your PR because there's a minor conflict

@bhavik-goplani
Copy link
Contributor Author

I ran the program using bend run and bend run-c
Yep, I'll rebase the PR. Thanks for the feedback!

@developedby
Copy link
Member

bend run doesn't have IO, only run-c and run-cu.

@developedby
Copy link
Member

Thank you for your contribution!

@bhavik-goplani
Copy link
Contributor Author

I'll try run-c again. Of course, I am happy to contribute. I'll pick another issue after this if that works with you.

@developedby developedby added this pull request to the merge queue Jul 5, 2024
Merged via the queue into HigherOrderCO:main with commit 29f2098 Jul 5, 2024
5 checks passed
@bhavik-goplani
Copy link
Contributor Author

I got the script to work and flush also works as expected.

def main:
  with IO:
    fd <- IO/FS/open("file.txt", "w")
    data = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
    write <- IO/FS/write(fd, data)
    flush <- IO/FS/flush(fd)
    write <- IO/FS/write(fd, data)
    write <- IO/FS/write(fd, data)
    close <- IO/FS/close(fd)
    return close

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.

2 participants