Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Is `lazy` gone or what?

$
0
0

I think it’s almost fine as is. My two cents:

  1. No point in sugaring it only on the one side: lazy({}) as a sort of built-in, but no accessor (only fully qualified Lazy.force())
  2. force is a particularly bad name because it signals that an evaluation is being forced no matter if it has before or not (i.e., it actually suggests the opposite of what it does).
  3. For me, I would be happy with:
module Lazy = {
  let make: (unit => 'a) => t<'a>
  let get: t<'a> => 'a
  // and possibly
  let isEvaluated: t<'a> => bool
}

I think we could even do type t<'a> ={ get:unit => 'a } since it’s self-mutating anyway

Speaking of sugaring, I would love to see some sugar for deref, i.e. let x = myRef^ instead of let x = myRef.contents which is horribly ugly, leaky and verbose. ;]


Viewing all articles
Browse latest Browse all 2592

Trending Articles