I couldn’t find the answer here: https://github.com/gleam-lang/gleam/discussions/1122
Basically the title says it all, i’m just curious.
#What was the conclusion of the “optional arguments” discussion?
1 messages · Page 1 of 1 (latest)
No one has done the R&D work to figure out the details
Seems the community has largely lost interest
I‘d sponsor a welcome design a bit as I really like it but cannot even find time to update glacier
oh okay
thank you
I'm team @white thicket on this one. This simple function + complex function + builder if you really need it is the way to go
to keep it positive: For custom types: To me the direct types signify much clearer what’s going on. I have tried the above with flutter-like types and it is very verbose. The strangeness budget is very low compared to other convenience features that got added. For functions this can very used to extend the stdlib for instance by supplying other ranfom generators or having list.range that reads and works unambiguously and can be customized out of the box.
its been a while since we had this bikeshed
yeah, I like the builder structure better too, if you design it well it becomes a tidy little DSL that's easy to read
its been a while since we had this bikeshed
just imagine how aggressive this had sounded if people said that about use to its apologets?
anyway, partisanship here won't help with the negative vibe, nor downplaying that others seem to find it useful.
the problem isn't that people want it, it's that it's never gotten past the "wouldn't it be nice" stage and the most that happens is a conversation about the broad outlines of the proposal
i found the proposal for default arguments for constructors extremely nice, even without default arguments for functions i think that's something worth having... will have to read the rest of that discussion to figure out why that wasn't adopted yet
We're not going to have it for only constructor functions and not user defined functions
In Gleam they are the same
oh, i didn't know that ^^;
can't say i've missed optional arguments much for functions, it's just a pain for large nested types, but that could possibly also be alleviated by LSP
i do however end up writing most recursive functions in the form of:
pub fn do_thing(arg) {
do_thing_rec(arg, [])
}
fn do_thing_rec(arg, acc) {
...
}
which i think is pretty standard in erlang as well