So Hy has different forms used than either Common Lisp, Scheme, or Clojure?
That just makes me frustrated. I know Lisp is the urlang from which all dynamic languages come from, I know that it's mutable into your personal tastes, but can we please standardize on a previously used set of forms? I respect and encourage people's desires to make a toylang, but if you want to promote it into "language for other people", things like portability become more important. I'm a common lisp guy, so obviously those are the best. ;-) But more importantly, I can run Common Lisp from before I was born. And I love that longjevity of my code and other people's code.
This started out as a joke for PyCon / teaching folks how to use Python AST, and it's grown to be kinda useful for a few things -- Macros aren't there yet, and the language is immature / special-snowflake about some things, but it's generally saneish.
Since we do target Python AST we don't control the runtime (at all), since hy stored as a .pyc (or even use pdb to debug lisp in Python, wat) it's really (really) hard to build up a traditional lisp.
Ah, thanks for the history. That provides context. I am afraid my contributions would be to provide rewrites and so forth to attempt to adhere to a subset of Common Lisp.
We don't have control of the runtime - the runtime is actually just Python -- in fact, a generated Hy .pyc can run on a system without Hy installed on it - so keeping it compliant to anything would just be insane.
We're also taking from Python's work - working with MongoDB or using requests + clint to write a 2 minute API wrapper is like 5 lines of code in hy :)
Interesting to see Clojure's syntax of using vectors ( '[]' ) in some places where previous LISPs have used lists being adopted here, at least for defn.
> As far as I know, the only way to access elements of the dictionary is through functions. I fear these methods are deprecated in future versions in favor of the square brackets [] notation.
I presume ``(.__getitem__ obj key)`` would work, or at least ``(obj.__getitem__ key)``.
``dict.get(key)`` is not deprecated. It's quite different to ``obj[key]`` (i.e. ``dict.__get__(obj, key)``) and is very useful:
>>> help(dict.get)
Help on method_descriptor:
get(...)
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
It's not from a Scheme viewpoint, and specifically SICP, which is where he's starting from.
Frankly, I'd prefer if it were idiomatic to locally defn inside Clojure defns, letfn is not hardly so elegant or clear. One of a number of areas where I find Clojure needlessly less tasteful and elegant than Scheme, but all are at least tolerable.
in Python one function definition inside another is totally normal, and (to my knowledge) the statement doesn't generate a global binding, so that the inner-defined function is not accessible from outside the outer one. In other words, python's def appears to be syntactic sugar for variable assignment within whatever scope you're already in, except of course that there is no nonsugared form. Which would make it analogous to let, I believe.
That just makes me frustrated. I know Lisp is the urlang from which all dynamic languages come from, I know that it's mutable into your personal tastes, but can we please standardize on a previously used set of forms? I respect and encourage people's desires to make a toylang, but if you want to promote it into "language for other people", things like portability become more important. I'm a common lisp guy, so obviously those are the best. ;-) But more importantly, I can run Common Lisp from before I was born. And I love that longjevity of my code and other people's code.
http://docs.hylang.org/en/latest/