Live data from Hacker News

Lisp in Dart 2.0

github.com

1–10 of 22 posts

Re: Lisp in Dart 2.0

#3
"A sort of subset of Emacs Lisp, but being Lisp-1 with lexical scoping"

Couldn't we please base such things on scheme or clojure (for Lisp-1) or common lisp (for Lisp-2).

Re: Lisp in Dart 2.0

#5
post #4

"Tail call optimization, which also implies tail recursion optimization" I thought those were exactly same thing.

Tail call optimization is returning the result of any function, with tail recursion being the specific case where it's the same function. I think I've seen some languages where they special-case recursion by doing a code transformation, but would stack overflow if you called anything else instead.

Re: Lisp in Dart 2.0

#6
post #4

"Tail call optimization, which also implies tail recursion optimization" I thought those were exactly same thing.

In a language with guranteed tail call optimization, the below consumes no stack, although there's no recursion.

    def f(a):
       return g(2*a)

    def g(a):
       return a + 1

Re: Lisp in Dart 2.0

#7
post #2

I have only one question: what is the purpose of this stuff? Was it made to extend the possibilies of Dart?

It looks like it was for fun. The author has several repositories on Github holding Lisp interpreters in different languages. It might also be a learning technique: interpreters for higher order languages are good intermediate projects when learning new languages.

Re: Lisp in Dart 2.0

#8
post #5
post #4

"Tail call optimization, which also implies tail recursion optimization" I thought those were exactly same thing.

Tail call optimization is returning the result of any function, with tail recursion being the specific case where it's the same function. I think I've seen some languages where they special-case recursion by doing a code transformation, but would stack overflow if you called anything else instead.

I don't think this is strictly correct. The below is (mutually) tail recursive:

   def even(x):
       return x == 0 or odd(abs(x)-1)

   def odd(x):
       return x == 1 or even(abs(x)-1)

Re: Lisp in Dart 2.0

#9
post #4

"Tail call optimization, which also implies tail recursion optimization" I thought those were exactly same thing.

You can also optimize non-recursive tail calls:

  def add10(y: int) -> int:
      return y+10

  def def add11(x: int) -> int:
      # won't get optimized
      return add10(x)+1

  def add11_tail(x: int) -> int:
      # should get optimized
      return add10(x+1)
in `add11_tail` the call to `add10` is in the tail position, i.e. you can "forget" about `add11_tail`'s stack frame since it's not needed anymore. It's still needed in `add10`, because you start in `add11`, call `add10` and go back to to `add11` to add 1 to the result.

Re: Lisp in Dart 2.0

#10
post #6
post #4

"Tail call optimization, which also implies tail recursion optimization" I thought those were exactly same thing.

In a language with guranteed tail call optimization, the below consumes no stack, although there's no recursion. def f(a): return g(2*a) def g(a): return a + 1

Ah, you beat me to it! I was writing my comment and then forgot about the tab for a while.
Post reply on HN