News for hackers. Stuff that matters.
Re:Lisp is sin by lispm on Tuesday September 01, 2009 @03:09PM (#798633)
I would format the function like this:

    (defun memoize (fn)
      (let ((cache (make-hash-table :test #'equal)))
        (lambda (&rest args)
          (multiple-value-bind (val win)
                               (gethash args cache)
            (if win
              val
              (setf (gethash args cache) (apply fn args)))))))
I'm a Lisp programmer and the C# arglist is already hard to parse with lots of noise - for me.

Second I don't look for { or ( but for the block indentation, so a { on a single line does not give me enough visual clues.

The 'return arg =>' form is not obvious to me. What does it do? Where dies TReturn come from, TParam?

Why is there }; and } ?

Re:Lisp is sin by pyre on Tuesday September 01, 2009 @06:41PM (#799092)
> Second I don't look for { or ( but for the block indentation, so a { on a single line does not give me enough visual clues.

We could argue for days about these sort of issues, and there are passionate ideas on either side of the fence.

  function
  {
    code;
    code;
  }
In that form, you have the beginning { and ending } for explicitly define the beginning and ending of the code block, and all of the code inside is also indented for good measure. Maybe it's redundant, but I don't see how it's wildly different from:

  function
    code;
    code;
> Why is there }; and } ?

Have you never programmer outside of lisp? I've never programmed in C#, but if 'arg =>' is the beginning of lambda, then it's because the definition of that line is return EXPRESSION;.

And in that case EXPRESSION = 'arg => { code }'. That's where the ';' comes from.

Re:Lisp is sin by snprbob86 on Tuesday September 01, 2009 @04:12PM (#798804)
=> denotes a lambda. The left side is the args, the right side is the body. Lambdas are typically a single expression, but can have a statement body instead. A semicolon denotes the end of a statement.

  var square = x => x * x;

  var square = x => { return x * x; };