Hacker News new | past | comments | ask | show | jobs | submit login

Unfortunately Emacs doesn't support any notion of prototypes.

Sure it does - just cons stuff onto assoc lists. I think PG mentioned this at the end of his "Arc lessons" essay.




True, but note that alists run in linear time. They're great for some things, but you probably don't want one with thousands of entries.

You could use hashtables instead, but the syntax for hashtables in Emacs Lisp is cumbersome.


I've only had a small amount of experience with Lisp, so I'm just curious: would macros solve syntactic problems like that?


Not really. There isn't really any major reason why you'd need to wrap it in a macro, because it's not enough code to be worth running at compile time, and you don't need to control evaluation order.

The bigger problem in elisp is that it doesn't have any kind of remotely sane namespacing, so instead of being something like Hashtable.make and Hashtable.set (which you could alias to HT.make and HT.set if you like), functions are either scattered all over the one global namespace or are all prefixed with cumbersome-package-name-. You could alias them all individually, but at that point it really doesn't contribute much to readability.

The potential solution probably involves read macros, which (for example) convert 'STATE to (quote STATE) at read-time. Having read macros that could convert e.g. x[23] to (nth 23 x), x['key 'val] to (puthash 'key 'val x), etc. would be quite enough, but read macros are prefix, and [23]x really doesn't do it for me. (I'm experimenting with adding postfix read macros to a Scheme-ish interpreter of mine, but I haven't found a good way to make it fit the rest of Lisp comfortably yet.)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: