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

BitArrays #7

Open
2 tasks
Tracked by #3
josh-degraw opened this issue Oct 7, 2024 · 1 comment
Open
2 tasks
Tracked by #3

BitArrays #7

josh-degraw opened this issue Oct 7, 2024 · 1 comment

Comments

@josh-degraw
Copy link
Owner

josh-degraw commented Oct 7, 2024

  • BitArray construction
  • BitArray pattern matching (do we disallow some kinds of matching like how js does?)
@josh-degraw josh-degraw mentioned this issue Oct 7, 2024
7 tasks
@RNGKing
Copy link
Collaborator

RNGKing commented Oct 7, 2024

I don't believe in "safe" dotnet you can access things on a bit by bit basis, the smallest unit is the byte.

Sample Gleam

pub fn main() {
  io.println("Hello from hello_world!")
  let bits = <<3:size(8)>>
  case bits {
    <<head, tail>> -> {
      io.println("have some bits")
      io.debug(head)
      io.debug(tail)
    }
    _ -> {
      io.println("everything else")
      0
    }
  }
}

Output Javascript

export function main() {
  $io.println("Hello from hello_world!");
  let bits = toBitArray([sizedInt(3, 8, true)]);
  if (bits.length == 2) {
    let head = bits.byteAt(0);
    let tail = bits.byteAt(1);
    $io.println("have some bits");
    $io.debug(head);
    return $io.debug(tail);
  } else {
    $io.println("everything else");
    return 0;
  }
}

So the equivalent F# should look something like the JS imo.

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

2 participants