Vladimir Sedach vsedach@gmail.com writes: [...]
How about two new forms? One for the current use of slot-value, and one for method calls?
Something like slot-value is needed (see below about @), but why is everyone obsessing about special syntax for method calls? JavaScript does not have any special syntax for method calls aside from the arglist curly braces (which is just the JS equivalent of funcall).
The reason is that method calls are often used and funcall is rather long-winded. I use ! for a method call, e.g. (dolist (script (! (element get-elements-by-tag-name) "script")) (eval (~ script inner-h-t-m-l)))
Here's the mess
(ps:defpsmacro ~ (&rest object-paths) (let ((slot (first (last object-paths))) (object-paths (butlast object-paths))) (cond ((not object-paths) slot) (t `(slot-value ,(if (rest object-paths) `(~ ,@object-paths) (first object-paths)) ',slot)))))
(ps:defpsmacro ! ((&rest object-paths) &rest args ) `(funcall (~ ,@object-paths) ,@args))
Though I note that ~ is actually just a worse way of doing @, which is already in parenscript.
[...]
Yes. I'm going to interpret this as a vote to remove 'slot-value' and keep just the '@' because 'slot-value' does not behave anything like its CL equivalent. I think this idea has some merit.
I'm not sure there's a need to remove it . . . maybe deprecate it?
It's a bit annoying to have to keep rewriting all one's parenscript code :-)
I think the problem you are expressing John is that people have too many ways to do things in Parenscript which basically wind up as syntactic sugar. I like the sentiment and I'm going to put it into practice.
My idea is that if you are going to push to make parenscript be more common lispy, then you should decide carefully on the proper way to do it, because if you have to change it later everybody's parenscript code has to be redone (again).
PS. I've updated teepeedee2 to the new parenscript. Any chance of getting a link in the frameworks section of the parenscript webpage? (I wish to persuade people to take the tpd2 webapp framework stuff a bit more seriously rather than assuming it's just a webserver :-)
[...]