Stream: beginners

Topic: Stdout multiline?


view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:17):

Is there an stdout function that prints multiple lines? or just the line! one?

view this post on Zulip Luke Boswell (Dec 01 2025 at 09:19):

Just the line one for now

view this post on Zulip Luke Boswell (Dec 01 2025 at 09:19):

You could write one that wraps that

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:23):

oh there is no multiline string yet in the new roc?

input =
    """
    L68
    L30
    R48
    L5
    R60
    L55
    L1
    L99
    R14
    L82
    """

print! = |msg| {
    for line in msg.split_on("\n") {
        Stdout.line!(line)
    }
}

main! = |_args| {
    Stderr.line!("Hello")
    dbg input.trim()
    print!(input.trim())
    Ok({})
}

This produces no dbg output

view this post on Zulip Luke Boswell (Dec 01 2025 at 09:26):

multiline strings use double backslash \\

view this post on Zulip Luke Boswell (Dec 01 2025 at 09:26):

input =
    \\1 2
    \\3 4
    \\5 6

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:27):

Thanks! will be worth adding to Richard gist I think!

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:30):

I’ve removed my debug statement, and the program seems to still be trying to do some debug that creates an error:

❯ roc day01.roc
Hello
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82
error(gpa): memory address 0x1032c0040 leaked:
Unable to print stack trace: Unable to open debug info: MissingDebugInfo

error(gpa): memory address 0x1032c0080 leaked:
Unable to print stack trace: Unable to open debug info: MissingDebugInfo

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:31):

Is this an error I should try to minify and create an issue?

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:34):

It seems the memory leak is detected as soon as I add the 7th line in my multiline string.

input =
    \\L68
    \\L30
    \\R48
    \\L5
    \\R60
    \\L55
    \\L1 # <- memory leak triggers here
    #\\L99
    #\\R14
    #\\L82

print! = |msg| {
    for line in msg.split_on("\n") {
        Stdout.line!(line)
    }
}

main! = |_args| {
    #Stderr.line!("Hello")
    #dbg input
    print!(input.trim())
    Ok({})
}

view this post on Zulip Matthieu Pizenberg (Dec 01 2025 at 09:42):

I opened an issue with it: https://github.com/roc-lang/roc/issues/8525

view this post on Zulip Luke Boswell (Dec 01 2025 at 10:27):

Fixed in https://github.com/roc-lang/roc/pull/8527


Last updated: Dec 21 2025 at 12:15 UTC