llm
Download
51 lines 2.5 KiBTomoModified 2026-09-09 raw
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
# How parameter and field lists are spaced. Names sharing a type are separated
# like any other pair of arguments (`x, y:Int`); only the type they share waits
# for the last of them, and it stays against the name it belongs to.

func grouped(one, two:Int, three:Text -> Int)
    return two

func spread(a, b, c, d:Int -> Int)
    return a

# The same, long enough that the list has to break across lines: the two code
# paths that render an argument list used to disagree about this spacing.
func lengthy(first_argument, second_argument:Int, third_argument:Text, fourth_argument:[Int], fifth_argument:{Text:Int} -> Int)
    return first_argument

# The return type and the flags are part of what has to fit, so a signature can
# break on them alone. Once it does, they take a line of their own: left on the
# last parameter's line, after the comma that separates it from the next, they
# read as one more parameter.
func on_the_suffix(arg1:Int, arg2:Int, arg3:Int, arg4:Int, arg5:Int, arg6:Int, arg7:Int, arg8:Int -> {Text:[Int]})
    return {}

func flagged(arg1xx:Int, arg2:Int, arg3:Int, arg4:Int, arg5:Int, arg6:Int, arg7:Int, arg8:Int -> Int; inline; cached)
    return arg2

convert (arg1xxxxxxxx:Int, arg2:Int, arg3:Int, arg4:Int, arg5:Int, arg6:Int, arg7:Int, arg8:Int -> Text)
    return "$arg2"

func anonymous(-> func(a,b,c,d,e,f:Int -> Int))
    # An anonymous function's signature breaks the same way a named one's does:
    return func(first_argument:Int, second_argument:Int, third:Int, fourth:Int, fifth:Int, sixth:Int -> Int)
        first_argument

# A short flag alias travels with the name it aliases:
func main.go(paths:[Text], force|f:Bool=no, count|n:Int=1)
    say("$paths $force $count")

# A struct's fields and an enum's variants break the same way a parameter list
# does, and the flags follow the same rule the return type does: a line of
# their own, since after the last field's comma they would read as a field.
struct Packed{f1x:Bool, f2:Bool, f3:Bool, f4:Bool, f5:Bool, f6:Bool, f7:Bool, f8:Bool, f9:Bool; packed_bools}

enum Wide(Variant1{x:Int, y:Int}, Variant2{x:Int, y:Int}, Variant3{x:Int, y:Int}, Variant4{x:Int, y:Int}, Variant5{x:Int, y:Int}, Variant6{x:Int, y:Int})

# A variant is a field list too, so one that doesn't fit breaks inside the
# enum that holds it:
enum Nested(Small, Roomy{f1xxxxxxxxxxxxxxxxxxxxxxxxx:Float64, f2:Float64, f3:Float64, f4:Float64, f5:Float64, f6:Float64; packed_bools})

struct Grouped{x, y, z:Float64}
struct Mixed{pos, vel:Grouped, mass:Float64}
enum Tagged(Pair{a, b:Int}, Solo{t:Text})