#Why was `let assert` introduced to the language?

1 messages · Page 1 of 1 (latest)

native ridge
#

I like the simplicity of Gleam a lot. I like "one way of doing things" philosophy. No ifs - just case, no loops - just recursion, etc.
Now I wonder why was let assert introduced 🤔 If I'm not mistaken same functionality could be achieved by using case + panic. In the Gleam language tour it is mentioned that "this feature should be used sparingly". I wonder why having such feature at all then?

latent roost
#

It can provide better debug information than case + panic as it can include the pattern that didn't match

#

bool panic will be added too

#

which again is very similar to case + panic

heady wolf
latent roost
#

Oops

#

Yes, sorry

#

Gears always has my back!

native ridge
#

Thanks for providing the context. Just read the proposal Bool assert.

If it gets in then Gleam will have few ways for panicking: panic, let assert, bool assert 🤔

#

Hmm I guess this part of the language feels different from the others from my (new to the language) perspective. Few different ways of doing things = a bit of confusion 😄

#

Though I get different levels of context they can provide - just a message, module/function/line, runtime value which caused the problem, ...

latent roost
#

It's the most duplicated bit of the language, for sure.