Merge branch 'master' into pr/522
This commit is contained in:
commit
2b08674c88
1
AUTHORS
1
AUTHORS
@ -46,3 +46,4 @@
|
||||
* Brendan Curran-Johnson <brendan@bcjbcj.ca>
|
||||
* Ivan Kozik <ivan@ludios.org>
|
||||
* Allison Kaptur <allison.kaptur@gmail.com>
|
||||
* Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
|
||||
|
44
CONTRIBUTING.rst
Normal file
44
CONTRIBUTING.rst
Normal file
@ -0,0 +1,44 @@
|
||||
Contributions are welcome & greatly appreciated, every little bit
|
||||
helps in making Hy more awesome.
|
||||
|
||||
Pull requests are great! We love them, here is a quick guide:
|
||||
|
||||
- Fork the repo, create a topic branch for a feature/fix. Avoid
|
||||
making changes directly on the master branch
|
||||
|
||||
- All incoming features should be accompanied with tests
|
||||
|
||||
- Before you submit a PR, please run the tests and check your code
|
||||
against the style guide. You can do both these things at once::
|
||||
|
||||
$ make d
|
||||
|
||||
- Make commits into logical units, so that it is easier to track &
|
||||
navigate later. Before submitting a PR, try squashing the commits
|
||||
into changesets that are easy to come back to later. Also make sure
|
||||
you don't leave spurious whitespace in the changesets, this avoids
|
||||
creation of whitespace fix commits later.
|
||||
|
||||
- As far as commit messages go, try to adhere to
|
||||
the following:
|
||||
|
||||
+ Try sticking to the 50 character limit for the first line of git
|
||||
commit messages
|
||||
|
||||
+ For more explanations etc. follow this up with a blank line and
|
||||
continue describing the commit in detail
|
||||
|
||||
|
||||
- Finally add yourself to the AUTHORS file (as a separate commit), you
|
||||
deserve it :)
|
||||
|
||||
- All incoming changes need to be acked by 2 different members of
|
||||
Hylang's core team. Additional review is clearly welcome, but we need
|
||||
a minimum of 2 signoffs for any change.
|
||||
|
||||
- If a core member is sending in a PR, please find 2 core members that doesn't
|
||||
include the PR submitter. The idea here is that one can work with the PR
|
||||
author, and a second acks the entire change set.
|
||||
|
||||
- For documentation & other trivial changes, we're good to merge after one
|
||||
ACK. We've got low coverage, so it'd be great to keep that barrier low.
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
# Base image
|
||||
#
|
||||
# VERSION 0.1
|
||||
FROM debian:unstable
|
||||
MAINTAINER Paul R. Tagliamonte <paultag@debian.org>
|
||||
|
||||
RUN apt-get update && apt-get install -y python3.4 python3-pip
|
||||
ADD . /opt/hylang/hy
|
||||
RUN python3.4 /usr/bin/pip3 install -e /opt/hylang/hy
|
||||
|
||||
CMD ["hy"]
|
12
NEWS
12
NEWS
@ -60,7 +60,7 @@ Changes from 0.9.12
|
||||
* "clean" target added to Makefile
|
||||
* hy2py supports a bunch of commandline options to show AST, source etc.
|
||||
* Sub-object mangling: every identifier is split along the dots & mangled
|
||||
seperately
|
||||
separately
|
||||
|
||||
[ Bug Fixes ]
|
||||
* Empty MacroExpansions work as expected
|
||||
@ -88,7 +88,7 @@ Changes from Hy 0.9.11
|
||||
what exactly was added.
|
||||
|
||||
The biggest feature, Reader Macros, landed later
|
||||
in the cycle, but were big enough to warrent a release on it's
|
||||
in the cycle, but were big enough to warrant a release on its
|
||||
own. A huge thanks goes to Foxboron for implementing them
|
||||
and a massive hug goes out to olasd for providing ongoing
|
||||
reviews during the development.
|
||||
@ -267,7 +267,7 @@ Changes from Hy 0.9.6
|
||||
|
||||
* UTF-8 encoded hy symbols are now hy_... rather than __hy_..., it's
|
||||
silly to prefex them as such. (PT)
|
||||
* `j' is no longer always intepreted as a complex number; we use it much
|
||||
* `j' is no longer always interpreted as a complex number; we use it much
|
||||
more as a symbol. (ND)
|
||||
* (decorate-with) has been moved to (with-decorate) (JD)
|
||||
* New (unless) macro (JD)
|
||||
@ -286,7 +286,7 @@ Changes from Hy 0.9.6
|
||||
and jd for making this happen. This solves just an insane number
|
||||
of bugs. (ND, PT, JD)
|
||||
* Eval no longer sucks with statements (ND)
|
||||
* New magic binary flags / mis fixes with the hy intepreter
|
||||
* New magic binary flags / mis fixes with the hy interpreter
|
||||
(WKG + @eigenhombre)
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ Changes from Hy 0.9.5
|
||||
=============== WARNING: WARNING: READ ME: READ ME: ===================
|
||||
From here on out, we will only support "future division" as part of hy.
|
||||
This is actually quite a pain for us, but it's going to be quite an
|
||||
amazing feautre.
|
||||
amazing feature.
|
||||
|
||||
This also normalizes behavior from Py 2 --> Py 3.
|
||||
|
||||
@ -346,7 +346,7 @@ Changes from Hy 0.9.4
|
||||
|
||||
* Statements in the `fn' path early will not return anymore. (PT)
|
||||
* Added "not" as the inline "not" operator. It's advised to still
|
||||
use "not-in" or "is-not" rather then nesting. (JD)
|
||||
use "not-in" or "is-not" rather than nesting. (JD)
|
||||
* `let' macro added (PT)
|
||||
* Added "~" as the "invert" operator. (JD)
|
||||
* `catch' now accepts a new format: (JD)
|
||||
|
@ -25,7 +25,7 @@ OK, so, why?
|
||||
------------
|
||||
|
||||
Well. Python is awesome. So awesome, that we have so many tools to alter the
|
||||
languge in a *core* way, but we never use them.
|
||||
language in a *core* way, but we never use them.
|
||||
|
||||
Why?
|
||||
|
||||
|
@ -89,26 +89,10 @@ To build the docs in HTML::
|
||||
Write docs---docs are good! Even this doc!
|
||||
|
||||
|
||||
Core Development Rules
|
||||
======================
|
||||
|
||||
Pull requests are good!
|
||||
|
||||
Before you submit a PR, please run the tests and check your code against the style guide. You can do both these things at once::
|
||||
|
||||
$ make d
|
||||
|
||||
All incoming changes need to be acked by 2 different members of Hylang's
|
||||
core team. Additional review is clearly welcome, but we need a minimum of
|
||||
2 signoffs for any change.
|
||||
|
||||
If a core member is sending in a PR, please find 2 core members that don't
|
||||
include the PR submitter. The idea here is that one can work with the PR
|
||||
author, and a second acks the entire change set.
|
||||
|
||||
If the change is adding documentation, feel free to just merge after one
|
||||
ACK. We've got low coverage, so it'd be great to keep that barrier low.
|
||||
Contributing
|
||||
============
|
||||
|
||||
.. include:: ../CONTRIBUTING.rst
|
||||
|
||||
Core Team
|
||||
=========
|
||||
|
@ -1144,7 +1144,7 @@ Example usage
|
||||
; Throw an IOError("foobar")
|
||||
|
||||
|
||||
`throw` can acccept a single argument (an `Exception` class or instance), or
|
||||
`throw` can accept a single argument (an `Exception` class or instance), or
|
||||
no arguments to re-raise the last Exception.
|
||||
|
||||
|
||||
@ -1238,7 +1238,7 @@ while
|
||||
`while` form is used to execute a single or more blocks as long as a condition
|
||||
is being met.
|
||||
|
||||
The following example will output "hello world!" on screen indefinetely:
|
||||
The following example will output "hello world!" on screen indefinitely:
|
||||
|
||||
.. code-block:: clj
|
||||
|
||||
|
@ -387,7 +387,7 @@ for a more complete description.) ``nif`` is an example, something like a numeri
|
||||
where based on the expression, one of the 3 forms is called depending on if the
|
||||
expression is positive, zero or negative.
|
||||
|
||||
A first pass might be someting like:
|
||||
A first pass might be something like:
|
||||
|
||||
.. code-block:: hy
|
||||
|
||||
|
@ -70,4 +70,4 @@ and expression is passed to the correct function.
|
||||
.. warning::
|
||||
Because of a limitation in Hy's lexer and parser, reader macros can't
|
||||
redefine defined syntax such as ``()[]{}``. This will most likely be
|
||||
adressed in the future.
|
||||
addressed in the future.
|
||||
|
@ -500,7 +500,7 @@ Let's take the classic:
|
||||
|
||||
(loop (print (eval (read))))
|
||||
|
||||
Rather then write it like that, we can write it as follows:
|
||||
Rather than write it like that, we can write it as follows:
|
||||
|
||||
.. code-block:: clj
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env hy
|
||||
;; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2013 under the terms
|
||||
;; of the Expat license, a copy of which you have should have recieved with
|
||||
;; of the Expat license, a copy of which you should have received with
|
||||
;; the source.
|
||||
|
||||
(import sys)
|
||||
|
@ -1751,18 +1751,19 @@ class HyASTCompiler(object):
|
||||
def _compile_assign(self, name, result,
|
||||
start_line, start_column):
|
||||
result = self.compile(result)
|
||||
|
||||
if result.temp_variables and isinstance(name, HyString):
|
||||
result.rename(name)
|
||||
return result
|
||||
|
||||
ld_name = self.compile(name)
|
||||
st_name = self._storeize(ld_name)
|
||||
|
||||
result += ast.Assign(
|
||||
lineno=start_line,
|
||||
col_offset=start_column,
|
||||
targets=[st_name], value=result.force_expr)
|
||||
if result.temp_variables \
|
||||
and isinstance(name, HyString) \
|
||||
and '.' not in name:
|
||||
result.rename(name)
|
||||
else:
|
||||
st_name = self._storeize(ld_name)
|
||||
result += ast.Assign(
|
||||
lineno=start_line,
|
||||
col_offset=start_column,
|
||||
targets=[st_name],
|
||||
value=result.force_expr)
|
||||
|
||||
result += ld_name
|
||||
return result
|
||||
@ -1855,7 +1856,7 @@ class HyASTCompiler(object):
|
||||
ret, args, defaults, stararg, kwargs = self._parse_lambda_list(arglist)
|
||||
|
||||
if PY34:
|
||||
# Python 3.4+ requres that args are an ast.arg object, rather
|
||||
# Python 3.4+ requires that args are an ast.arg object, rather
|
||||
# than an ast.Name or bare string.
|
||||
args = [ast.arg(arg=ast_str(x),
|
||||
annotation=None, # Fix me!
|
||||
|
@ -46,9 +46,10 @@
|
||||
|
||||
(defmacro ap-map [form lst]
|
||||
"Yield elements evaluated in the form for each element in the list."
|
||||
`(let [[f (lambda [it] ~form)]]
|
||||
(for [v ~lst]
|
||||
(yield (f v)))))
|
||||
(let [[v (gensym 'v)] [f (gensym 'f)]]
|
||||
`(let [[~f (lambda [it] ~form)]]
|
||||
(for [~v ~lst]
|
||||
(yield (~f ~v))))))
|
||||
|
||||
|
||||
(defmacro ap-map-when [predfn rep lst]
|
||||
|
@ -31,34 +31,6 @@
|
||||
[hy._compat [PY33 PY34]])
|
||||
|
||||
|
||||
(defmacro for [args &rest body]
|
||||
"shorthand for nested for loops:
|
||||
(for [x foo
|
||||
y bar]
|
||||
baz) ->
|
||||
(for* [x foo]
|
||||
(for* [y bar]
|
||||
baz))"
|
||||
|
||||
(if (odd? (len args))
|
||||
(macro-error args "`for' requires an even number of args."))
|
||||
|
||||
(if (empty? body)
|
||||
(macro-error None "`for' requires a body to evaluate"))
|
||||
|
||||
(if (empty? args)
|
||||
`(do ~@body)
|
||||
(if (= (len args) 2)
|
||||
; basecase, let's just slip right in.
|
||||
`(for* [~@args] ~@body)
|
||||
; otherwise, let's do some legit handling.
|
||||
(let [[alist (slice args 0 nil 2)]
|
||||
[ilist (slice args 1 nil 2)]]
|
||||
`(do
|
||||
(import itertools)
|
||||
(for* [(, ~@alist) (itertools.product ~@ilist)] ~@body))))))
|
||||
|
||||
|
||||
(defmacro with [args &rest body]
|
||||
"shorthand for nested for* loops:
|
||||
(with [[x foo] [y bar]] baz) ->
|
||||
@ -116,6 +88,26 @@
|
||||
root)
|
||||
|
||||
|
||||
(defmacro for [args &rest body]
|
||||
"shorthand for nested for loops:
|
||||
(for [x foo
|
||||
y bar]
|
||||
baz) ->
|
||||
(for* [x foo]
|
||||
(for* [y bar]
|
||||
baz))"
|
||||
(cond
|
||||
[(odd? (len args))
|
||||
(macro-error args "`for' requires an even number of args.")]
|
||||
[(empty? body)
|
||||
(macro-error None "`for' requires a body to evaluate")]
|
||||
[(empty? args) `(do ~@body)]
|
||||
[(= (len args) 2) `(for* [~@args] ~@body)]
|
||||
[true
|
||||
(let [[alist (slice args 0 nil 2)]]
|
||||
`(for* [(, ~@alist) (genexpr (, ~@alist) [~@args])] ~@body))]))
|
||||
|
||||
|
||||
(defmacro -> [head &rest rest]
|
||||
;; TODO: fix the docstring by someone who understands this
|
||||
(setv ret head)
|
||||
|
@ -54,7 +54,9 @@
|
||||
(assert-equal (list (ap-map (* it 3) [1 2 3]))
|
||||
[3 6 9])
|
||||
(assert-equal (list (ap-map (* it 3) []))
|
||||
[]))
|
||||
[])
|
||||
(assert-equal (let [[v 1] [f 1]] (list (ap-map (it v f) [(fn [a b] (+ a b))])))
|
||||
[2]))
|
||||
|
||||
(defn test-ap-map-when []
|
||||
"NATIVE: testing anaphoric map-when"
|
||||
|
@ -57,6 +57,34 @@
|
||||
(try (do (dec None) (assert False))
|
||||
(catch [e [TypeError]] (assert (in "not a number" (str e))))))
|
||||
|
||||
(defn test-setv []
|
||||
"NATIVE: testing setv mutation"
|
||||
(setv x 1)
|
||||
(setv y 1)
|
||||
(assert-equal x y)
|
||||
(setv x (setv y 12))
|
||||
(assert-equal x 12)
|
||||
(assert-equal y 12)
|
||||
(setv x (setv y (fn [x] 9)))
|
||||
(assert-equal (x y) 9)
|
||||
(assert-equal (y x) 9)
|
||||
(try (do (setv a.b 1) (assert False))
|
||||
(catch [e [NameError]] (assert (in "name 'a' is not defined" (str e)))))
|
||||
(try (do (setv b.a (fn [x] x)) (assert False))
|
||||
(catch [e [NameError]] (assert (in "name 'b' is not defined" (str e)))))
|
||||
(import itertools)
|
||||
(setv foopermutations (fn [x] (itertools.permutations x)))
|
||||
(setv p (set [(, 1 3 2) (, 3 2 1) (, 2 1 3) (, 3 1 2) (, 1 2 3) (, 2 3 1)]))
|
||||
(assert-equal (set (itertools.permutations [1 2 3])) p)
|
||||
(assert-equal (set (foopermutations [3 1 2])) p)
|
||||
(setv permutations- itertools.permutations)
|
||||
(setv itertools.permutations (fn [x] 9))
|
||||
(assert-equal (itertools.permutations p) 9)
|
||||
(assert-equal (foopermutations foopermutations) 9)
|
||||
(setv itertools.permutations permutations-)
|
||||
(assert-equal (set (itertools.permutations [2 1 3])) p)
|
||||
(assert-equal (set (foopermutations [2 3 1])) p))
|
||||
|
||||
(defn test-distinct []
|
||||
"NATIVE: testing the distinct function"
|
||||
(setv res (list (distinct [ 1 2 3 4 3 5 2 ])))
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
(defn test-for-loop []
|
||||
"NATIVE: test for loops?"
|
||||
"NATIVE: test for loops"
|
||||
(setv count 0)
|
||||
(for [x [1 2 3 4 5]]
|
||||
(setv count (+ count x)))
|
||||
@ -38,7 +38,11 @@
|
||||
(for [x [1 2 3 4 5]
|
||||
y [1 2 3 4 5]]
|
||||
(setv count (+ count x y)))
|
||||
(assert (= count 150)))
|
||||
(assert (= count 150))
|
||||
(assert (= (list ((fn [] (for [x [[1] [2 3]] y x] (yield y)))))
|
||||
(list-comp y [x [[1] [2 3]] y x])))
|
||||
(assert (= (list ((fn [] (for [x [[1] [2 3]] y x z (range 5)] (yield z)))))
|
||||
(list-comp z [x [[1] [2 3]] y x z (range 5)]))))
|
||||
|
||||
|
||||
(defn test-nasty-for-nesting []
|
||||
|
Loading…
x
Reference in New Issue
Block a user