39 ms·
Python natively supports this sort of list comprehension (https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions https://docs.python.org/2/t
by austinz 12y ago
Python natively supports this sort of list comprehension (https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions https://docs.python.org/2/tutorial/datastructures.html#list-...), and the Lisp source is being translated into a Python AST, so that snippet is probably being directly mapped into whatever AST form is necessary to invoke the list comprehension.
- Foxboron 12y agoYes thats correct. https://github.com/hylang/hy/blob/dcf29d3d2a147fe66a199712149f7b58fd7fef04/hy/compiler.py#L1370 https://github.com/hylang/hy/blob/dcf29d3d2a147fe66a19971214... Source for those interested. Note that Hy replaces all - in names for _, thus we can have prettier names :)
- rcarmo 12y agoOh, and earmuffs become EARMUFFS, which is also nice.
- paroneayea 12y agoYes that's exactly what's happening. Hy has two levels of things mostly: a "compiler" that does the low-level mapping of base python constructs (and whatever can be mapped to AST)... here's where list-comp is implemented: https://github.com/hylang/hy/blob/master/hy/compiler.py#L1370 https://github.com/hylang/hy/blob/master/hy/compiler.py#L137... Anything above that is written as Hy macros, in Hy itself: https://github.com/hylang/hy/blob/master/hy/core/macros.hy https://github.com/hylang/hy/blob/master/hy/core/macros.hy There's a lot of other core code that's written in Hy itself too. https://github.com/hylang/hy/tree/master/hy/core https://github.com/hylang/hy/tree/master/hy/core