jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

Uncaught effects #12

Closed aleclarson closed 6 years ago

aleclarson commented 6 years ago

What happens to uncaught effects?

jamiebuilds commented 6 years ago
UncaughtEffectError: Effect was never caught by a handler: 'myEffect'
   ...stack trace...
aleclarson commented 6 years ago

Crazy idea: Prepend the @ symbol to any function call to assume purity. Maybe perform some memoization? Any uncaught effects would crash at the callsite.

let foo = fn (a, b) {
  effect a + b * Math.random()
}

let res = @foo(a, b)
jamiebuilds commented 6 years ago

Effects are not impure