|
|
|
|
|
by throw009
1211 days ago
|
|
>Here, `_from_source` goes from a plain array of tokens to a nested one (tree), depending on their arity: You're 90% there. Lisp notation obviates the need for arity tracking, which is why in lisp + and sum are the same function: scheme@(guile-user)> (+)
$416 = 0
scheme@(guile-user)> (+ 1)
$417 = 1
scheme@(guile-user)> (+ 1 2)
$418 = 3
scheme@(guile-user)> (+ 1 2 3)
$419 = 6
Add higher order functions, e.g. (λ (x) (x x)), and lisp notation is the simplest/only way to deal with the general case where you don't know ahead of time the arity of the function you'd be applying because of partial currying and data persistence.As for the parsers this was 10 years ago at university. I've long since lost the source code. There weren't any problems with python, it's just that once I wrote the lisp version I realized just how useful the brackets actually are. There's a reason why every computer language is more or less context free. Lisp just takes that to its logical conclusion. |
|
Cheers!