[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SRFI 31 procedure vs. named-lambda (2)



Hello!

Here are some further remarks on my perception of the difference
between `named-lambda' and the proposed form `procedure', cf.
http://srfi.schemers.org/srfi-31/.

* The only implementation of `named-lambda' I'm aware of is in MIT
  Scheme. While appearing similar to the proposed `procedure', it is
  actually NOT so and does NOT capture the main point of `procedure'.
  
  If we want to form an expression denoting the factorial function
  using `named-lambda', it is NOT sufficient to write 

  (named-lambda (F N) 
		(if (zero? N) 1 
		    (* N (F (- N 1)))))

  This expression as it stands is NOT a name of the factorial. The
  following is an error:

  1 ]=> ((named-lambda (F N) (if (zero? N) 1 (* N (F (- N 1))))) 10)
  ;Unbound variable: f
  2 error> 

  Also the following does NOT work

  (define G (named-lambda (F N)
	    (if (zero? N) 1
		(* N (F (- N 1))))))

  again leading to an "Unbound variable: f" error.

  What DOES work is 

  (define F (named-lambda (F N)
	    (if (zero? N) 1
		(* N (F (- N 1))))))

  Chris Hanson informs me that this is the desired behavior of
  `named-lambda', not a shortcoming of the implementation.

  However, had we used the proposed `procedure' form instead of
  `named-lambda', all three examples above had worked.

* W.r.t. the question why `named-lambda' had been dropped from R2RS,
  Hal Abelson suggests that this was rather due to Scheme's minimality
  principle than due to technical reasons.

My point of view by now is the following.

  - MIT Scheme's `named-lambda' does not provide what SRFI-31 is
    looking for and it does so by will, not by accident.

  - R2RS Scheme's `named-lambda' probably didn't either. And even if
   it did, it's not in the Reports anymore for minimalistic reasons.
   In our case this sort of minimalism (which cannot be the ultimate
   goal anyway) contradicts another important principle, namely that
   of separation of concerns - stateless vs. imperative programming.

In conclusion I believe that `procedure' fills in a gap that obviously
exists at present and it does neither contradict any of Scheme's
principles, nor any previous decisions of Scheme's designers and
implementors.

Best regards, Mirko.