Hey, can i only define variables once? Is there a way to change this behavior
So currently, shadowing is disallowed. We are working on changing that now that this proposal has been accepted:
https://docs.google.com/document/d/1Ly5Cp_Z7dY8KLQkkDYZlGCldxQj4jLzZ0vIeB-F8lJI/edit?usp=sharing
It'll be at least a couple months before it's possible though
I'll probably be the one implementing most of that part of the proposal, so let me know if you have any questions!
that's cool
will for loops come too?
it could be an really need alternativ to ocaml then?
Does Roc have something like Ocaml References
I think so.
Yep, for loops will also come, I just don't know who is in charge of implementing them
Jonas said:
Does Roc have something like Ocaml References
I don't think we are thinking about any sort of explicit mutability
@Anthony Bullard I don't think we have refs?
Sam Mohr said:
Anthony Bullard I don't think we have refs?
Sorry there I was speaking towards whether Roc could be an alternative to OCaml
A ref is a value you can pass to other functions that is mutable. We don't currently have that, or plans for that
We won't have arenas either, but we are already using RC instead of M&S or pause-the-world GC
Or functors - but Module Params are an interesting alternative to that
And I think I can feel good in saying we definitely won't have an object system :-)
Sry, i am very new is Roc Pipe First or Last?
PIpe first
ok
You should find the data structure for all module functions in the first position in all of the builtins
are Records/Structs immutable as well?
Yes
:rolling_on_the_floor_laughing: then i still will have use for Ocaml, love how easy imports are and how fast
in ocaml i have to precompile everything it takes a while
The Roc compiler will be very fast compared to what you're used to, methinks
It'll just take us some time to get it all tied together
pkgs usallay complie to so files, so compliing the actual bin is quick
I thought Dune was pretty fast at building, but it's been awhile
But yes, Roc has different goals for Ocaml, they both have their uses
meant the liabary files
compiling them takes a while
Will there ever be a Roc unikernel? :wink:
but since they are precompiled dune just have to link them
the std is written in Rust, i don't need an Rust Compiler right(have one installed anyways)
even for basic-cli i guess
I think the platforms ship with the .a files you need and then roc uses llvm to assemble it (or just links it with the appropriate linker)
Here's the contents of basic-cli platform package:
Arg
Arg.roc
Cmd.roc
Dir.roc
Env.roc
EnvDecoding.roc
File.roc
FileMetadata.roc
Http.roc
InternalCommand.roc
InternalFile.roc
InternalHttp.roc
InternalPath.roc
Locale.roc
Path.roc
PlatformTasks.roc
Sleep.roc
Stderr.roc
Stdin.roc
Stdout.roc
Tcp.roc
Tty.roc
Url.roc
Utc.roc
glue.roc
libapp.roc
linux-arm64.a
linux-x64.a
linux-x64.rh
macos-arm64.a
macos-x64.a
main.roc
metadata_linux-x64.rm
Jonas said:
the std is written in Rust, i don't need an Rust Compiler right(have one installed anyways)
You should only ever need two things:
roc
compiler binaryAnthony Bullard said:
We won't have arenas either, but we are already using RC instead of M&S or pause-the-world GC
also platforms can use arenas behind the scenes - e.g. doing one arena per request like @Folkert de Vries 's nea
https://youtu.be/zMRfCZo8eAc?si=khwPJ-2BfTvuajYB
can i concat a string from an List?
Jonas said:
are Records/Structs immutable as well?
semantically they're immutable, although roc does "opportunistic mutation" where things get automatically mutated in place (instead of cloned) if their refcount is 1, because then the mutation is unobservable and can safely be done as a silent performance optimization behind the scenes
more details at https://youtu.be/vzfy4EKwG_Y?si=rE4ZhW3n7Kx3iKZo
Thanks for the clarification! Arena's are great for web requests
Which is why even Go played around with it (I think it was removed though in 1.23
Jonas said:
can i concat a string from an List?
Do you mean join a list of strings into one? Or a list of bytes (U8) into a string?
The answer is yes on both
Str.joinWith to join a (List Str, Str -> Str) and Str.fromUtf8 for (List U8 -> Str)
https://www.roc-lang.org/builtins/Str#joinWith
thanks
Last updated: Jul 06 2025 at 12:14 UTC