News for hackers. Stuff that matters.
Re:Why Lisp? by dragonwriter on Thursday May 07, 2015 @06:24PM (#9508770)
The point was that "debug" and "message" parts in the example were arbitrarily complex expressions which were computationally expensive to evaluate. Your wrapping of log debug would still require evaluating them to get the message string unconditionally, even when debug logging is not enabled.

Of course, with support for first-class functions, you could do something like:

  func debug(produceMessage ()->string) {
    if log.isDebugEnabled() {
      log.debug(produceMessage());
    }
  }
Re:Why Lisp? by snikeris on Thursday May 07, 2015 @07:34PM (#9509119)
And then what would I need to type to write a log message?
Re:Why Lisp? by ufo on Thursday May 07, 2015 @08:24PM (#9509315)
You pass a lambda that returns the debug message. With javascripty syntax:

    debug( function(){ return "my expensive log message" })
BTW, if your language is lazily evaluated (like Haskell) then you don't need to do this because arguments will only ve evaluated when they are needed.
Re:Why Lisp? by MichaelGG on Thursday May 07, 2015 @10:05PM (#9509636)
The downside there is you can still end up allocating a closure. Whereas an expanded macro shouldn't cost anything. (A sufficiently smart compiler might be able to optimize the closure allocation.)
Re:Why Lisp? by FeepingCreature on Friday May 08, 2015 @03:27AM (#9510403)
A sufficiently modern language (like, saaaaay, D2) could also give you a type like "closure you don't intend to escape" (let's call this a "scoped closure", or if you will, "scope string delegate()"), and eschew allocation entirely without requiring optimization.