gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Allow arithmetic guard expressions

Open manveru opened this issue 3 years ago • 3 comments

See https://www.erlang.org/doc/reference_manual/expressions.html#guard-expressions

manveru avatar Sep 09 '22 11:09 manveru

Thank you

lpil avatar Sep 10 '22 09:09 lpil

Thanks! It was pretty surprising to not be able to call very basic pure functions in gleam in guards. It's something i do quite often in ocaml. Would be rad if gleam tracked purity somehow (??maybe not possible??) and allowed a bit more capability than erlang does here... even if it means drastically different compiled output?

i dunno, i'm a rookie. don't listen to me ;)

cdaringe avatar Dec 01 '23 04:12 cdaringe

Hello! It's not just a matter of purity, the VM only permits certain operations in guards for performance reasons. It is not possible to support arbitrary pure expressions.

Purity tracking itself would be easy :)

lpil avatar Dec 01 '23 09:12 lpil

I'm having a go at implementing this.

DanielleMaywood avatar Jun 24 '24 17:06 DanielleMaywood