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

SRFI 31 procedure vs. named-lambda (2)

This page is part of the web mail archives of SRFI 31 from before July 7th, 2015. The new archives for SRFI 31 contain all messages, not just those from before July 7th, 2015.


Here are some further remarks on my perception of the difference
between `named-lambda' and the proposed form `procedure', cf.

* 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

Best regards, Mirko.