cqcallaw / newt

The newt programming language
GNU General Public License v3.0
12 stars 2 forks source link

Pure functions #35

Open cqcallaw opened 8 years ago

cqcallaw commented 8 years ago

It seems useful to flag functions without side effects as "pure"

cqcallaw commented 8 years ago

Pure functions should not reference their surrounding contexts in any way. I'm inclined to be hard line about it and also disallow closing over surrounding contexts by value

laokaplow commented 8 years ago

They should be able to use / make reference to constants in their surrounding context, including other pure functions.

cqcallaw commented 8 years ago

Hmmm, so you're advocating for functions that are statefully pure but referentially impure? That is, pure functions can't necessarily be copy/pasted into another scope or file?

cqcallaw commented 8 years ago

(from a verbal discussion) disallowing references to other pure functions makes it a pain in the rear to compose functions together into another pure function.