Hacker News new | ask | show | jobs
by ieure 6002 days ago
Nice start. I was considering something simliar, but I just didn't care enough about PHP to work on it.

Stuff that I'd like to see improved:

1. if/elseif/else syntax is pretty ugly. What are the chances of getting if/when/unless/cond?

2. Nicer array syntax. Maybe coopt the vector literal syntax, since PHP doesn't have anything similar: [1 2 3]. Failing that, quotes: '(1 2 3) -> array(1, 2, 3). Not sure how to handle cases where you would have something inside the quote that would eval, though.

3. Not thrilled with the superglobals/array syntax, which are more verbose (or the same, in the case of superglobals).

4. It isn't clear if/how this interacts with objects. Does it work like: (object->method arg1…argN)? What about static methods?

2 comments

Thanks for the suggestions.

1. Pretty likely, though I'm a little hesitant to replace the current syntax for if. The others shouldn't be hard to implement.

2. I've been planning to use the vector literal syntax. I've basically been lazy since PHP's array() construct makes it easy to cheat.

3. Indexing into arrays presents a problem. Pharen doesn't know what's a scalar, array, or function name at the moment so a special function for indexing is needed. One possible solution is to prefix an array's name, so it would be (:some_array 4) or something similar. I personally think the superglobal syntax is cleaner, if not more succinct. Any suggestions?

4. I haven't implemented an object system yet because I want to try something new here instead of simply copying PHP's syntax.

1. Perhaps you could keep the PHP-style syntax around under a different name.

2. Sweet.

3. (:some_array 4) seems perfectly reasonable. Would that interact with superglobals the same way? e.g. ($:server "PHP_SELF"). I believe that PHP 5.3 or 6 has return value dereferencing, so I don't think it's necessary to know the type - you could just do (:(array 1 2 3) 1)

4. If you haven't played with Clojure, you might find inspiration there. It has interop with native Java instances, though I find it a little too syntaxy for a Lisp, and PHP doesn't have such deep class structure.

Thanks for responding.

Yeah, the IF paren'ning is a nightmare on the scale that keeps a lot of people away from LISP.