Arc Forumnew | comments | leaders | submitlogin
1 point by rntz 5675 days ago | link | parent

GHC (the de facto standard Haskell compiler) uses "implicit parameters" as the name of an extension that is almost, but not quite, equivalent to dynamic binding. Namely, in Common Lisp, you have the following:

  CL-USER> (defvar *foo*)
  *FOO*
  CL-USER> (let ((f (let ((*foo* 0)) (lambda () *foo*)))) 
             (let ((*foo* 1)) (funcall f)))
  1
Whereas in Haskell with GHC extensions, you have:

  Prelude> :set -XImplicitParams
  Prelude> let f = (let ?x = 0 in \() -> ?x) in let ?x = 1 in f ()
  0
I think that, as "dynamic variables/binding" is the name that has always been used before, and "implicit variables/parameters" is a name used to refer to something subtly different, it might be better to use the former; but it doesn't really matter that much, and "implicit" does do a better job of getting across the purpose of dynamic binding than just calling it "dynamic".


1 point by aw 5675 days ago | link

That's interesting that Haskell also uses the term "implicit". The differences seem mostly related to the type system. For example, since the variables are statically typed, it's easy for them to overload "let" to do dynamic binding with implicit parameters. Is there some other subtle difference that I'm missing?

The "it's always been called X before" argument would prevent us from ever improving the language by coming up with better names; we'd still be calling anonymous functions "lambda" instead of "fn" etc.

-----

1 point by rntz 5659 days ago | link

Er, see the post you replied to: that code I gave is precisely the same modulo syntax, but in Common Lisp it evaluates to 1 and in Haskell to 0. Essentially, Haskell's implicit variables don't allow rebinding/shadowing. It's a bid hard to explain, but look at the example and play around a bit and you'll see what I mean.

-----

1 point by aw 5658 days ago | link

Ah, I don't know enough Haskell to really be able to see what's going on. Thank you for the description though.

-----