4 ms·
Since Lisphp is a new dialect, you don't need to worry about backward-compatibility. You should get rid of car/cdr entirely. There is no inherent reason for usi
by sedachv 16y ago
Since Lisphp is a new dialect, you don't need to worry about backward-compatibility. You should get rid of car/cdr entirely. There is no inherent reason for using linked lists for anything - even s-expressions. For example, no one has ever complained about the lack of car/cdr in Parenscript (although to be fair, Parenscript is not homoiconic, just a translator from CL to JS). Having a good backquote-comma templating syntax is more valuable.
You should even get rid of a custom type for Lisphp sequences and use PHP arrays directly. Ditto all other datatypes. Then if you use PHP's calling convention you should be able to call PHP code directly without needing USE and FROM, and more importantly PHP code can do the same to Lisphp with minimal pain. That way writing Lisphp libraries for others to use becomes viable.
- jacquesm 16y agoI think it's actually quite neat that it tries to stay close to the lisp code that you see in examples and books about lisp.
- sedachv 16y agoWhat's the point of sacrificing something like platform integration for car/cdr? Anyone who is going to want to use Lisphp for real work is not going to have a problem writing their code to use arrays. Anyone who thinks that car/cdr is more valuable than platform integration is not going to use Lisphp for real work. And everyone else will come by and say "Lisphp has those weird car/cdr and it can't even work with PHP libraries without glue code, Lisp is a toy."
- KirinDave 16y agoCall them what you want. First/car & rest/cdr are the classic tool for writing code that iterates across datasets.
- sedachv 16y agoRecursion, map, and fold can be used for iteration. car/cdr is just one way to access elements of a sequence.
- KirinDave 16y agoThink about what you just said and why it's not a valid rebuttal. I know you know better. Hint: via recursion, how do you advance along a sequence in a collection-agnostic way?
- sedachv 16y agoSo now iterators mean car/cdr is "classic" so it should be present in all Lisp dialects from here to eternity?
- KirinDave 16y agoAgain, you can call them "first" and "rest" if you like. It is the ability to decompose an arbitrary sequential data structure efficiently that is important. It's not important because of any historical bias; it's important because it is incredibly useful. If you can't support first/rest in an efficient manner, it is a bad sign.
- sedachv 16y agoSo all those other programming languages that come with arrays and not linked lists are completely useless? Mildly useless? Only kind of useless? Or is it the case that it really doesn't matter?
- KirinDave 16y agoMost of them DO provide a way to do this. For example, Ruby is array based but provides a way to do this through enum. The lispish way is first/rest. Clojure, a lisp with very novel data structures, does this just fine even with associative arrays and vectors. It introduces a seq abstraction to support it. It's important when you need to write your own iteration primitives. Map, fold, etc are all well and good, but sometimes they won't do because the iteration may require some unusual steps. In your particular dialect of lisp, what does the code for writing map or fold look like? The one that doesn't copy memory egregiously, that is. And how bad must the performance of javascript linked lists be to scare you away from them so damn hard, anyways? Or perhaps, what you're supporting is a "lispish" language that isn't really something we should directly compare to lisp, in the vein of Nu?
- jrockway 16y agoThere is no inherent reason for using linked lists for anything Uh, constant-time insertions?
- sedachv 16y agoDid you read the parent post?