Commit Graph

685 Commits

Author SHA1 Message Date
Kodi Arfer
5eb928356a Overhaul semantics of binary operators (#1261)
I've added shadow versions of many operators that didn't have one. And, I've changed the behavior of various binary operators with more or fewer than 2 arguments to make the shadow and real versions more consistent and to make the behavior more logical in either case. For details, see the additions to NEWS and the new file tests/native_tests/operators.hy, which simultaneously tests shadow and real operators.

Although there are a lot of changes, I've put them all in one commit because they're interdependent.
2017-04-13 19:42:01 -05:00
Kodi Arfer
18acfe6495 Revert the extension of with-decorator to setv
This is no longer necessary now that `defn` always produces a `FunctionDef`.

To compensate, I've made small edits to two contrib modules and reverted a small test change.
2017-04-13 06:36:00 +03:00
Kodi Arfer
7c203abe4d Fix bug with unset __name__ of one-line functions
The bug was a regression that I introduced in #1228.

I've created a new special form named `fn*` that works like the old `fn` (that is, it always creates a `FunctionDef`). Since this is intended only for internal use, like `with*`, I haven't documented it.
2017-04-13 06:36:00 +03:00
Kodi Arfer
491b474e7f Make setv return None for more types of rvalues 2017-04-07 21:21:19 +03:00
Kodi Arfer
286d568959 Fix a crash when tokenizing a single quote 2017-04-07 21:12:17 +03:00
Tuukka Turto
4a5e2fd852 Merge branch 'master' into walk-loop 2017-04-01 08:15:10 +03:00
Kodi Arfer
a7085138f6 Add tests for #533 2017-03-30 16:10:34 -07:00
Kodi Arfer
5aadeba3fe Fix bug: loop replaced strings equal to "recur" 2017-03-30 15:49:10 -07:00
Kodi Arfer
e478008cce Fix HyMacroExpansionError underline alignment 2017-03-24 11:09:30 -07:00
Kodi Arfer
ca1bd0ffd3 Add a test for as-> in the REPL
Closes #1255.
2017-03-24 09:03:55 -07:00
Kodi Arfer
33a696d487 Add a command-line option --repl-output-fn (especially for hy.contrib.hy-repr) 2017-03-24 09:03:12 -07:00
Kodi Arfer
bf2f90a0d9 Add hy.contrib.hy-repr 2017-03-24 08:43:53 -07:00
Kodi Arfer
32e76caafe Refactor test_bin 2017-03-24 08:43:53 -07:00
Kodi Arfer
ae1dd78c53 Make setv always return None 2017-03-24 06:38:30 +02:00
Tuukka Turto
2ee91f6dc6 Merge branch 'yield-ret'
Conflicts:
	NEWS
2017-03-19 22:26:13 +02:00
Ryan Gonzalez
7c82c01a6a Fix #151 (again!): yield inside with wasn't propagated to Result 2017-03-08 16:04:48 -06:00
Kodi Arfer
5f00921dea Fix #1243: read raises EOFError on false inputs (#1244)
* Fix #1243: `read` raises EOFError on false inputs

* Fix crash when trying to `eval` false values
2017-03-06 10:51:25 -06:00
Kodi Arfer
8b6a45e43a Remove car and cdr in favor of first and rest (#1241)
* Remove uses of `car` and `cdr` in /hy

* Remove uses of `car` and `cdr` in quote tests

* Remove `car` and `cdr` in favor of `first` and `rest`

I beefed up the documentation and tests for `first` and `rest` while I was at it.

I defined `car` and `cdr` in native_tests.cons so the tests read a bit more naturally.
2017-03-06 10:34:40 -06:00
Kodi Arfer
8ecb17d1fd Fix bug: quoting a bytestring raises ImportError (#1245) 2017-03-04 19:04:28 -06:00
Kodi Arfer
6620cc4e6f Merge pull request #1235 from Kodiologist/test-reorg
Minor test reorganization
2017-03-02 18:45:17 -08:00
Kodi Arfer
484daafa53 Move hy.core.reserved to hy.extra.reserved (#1231)
It was an odd one out by being in hy.core but needing to be called by a qualified name. It's at home in hy.extra.
2017-03-02 16:49:32 -06:00
Kodi Arfer
ebfa636b50 Fix #1237: iterator-handling bug in partition
Also, `partition` with n < 0 now raises an error.
2017-02-26 20:37:35 +02:00
Kodi Arfer
d649147b0c Minor test reorganization
This removes two singleton directories.
2017-02-24 12:47:35 -08:00
Kodi Arfer
e4a7b317e1 Make fn work like lambda and remove lambda (#1228)
* with-decorator: Allow a `setv` form as the form to be decorated

This feature is of dubious value by itself, but it's necessary to allow `defn` to create a lambda instead of a `def`.

* Make `fn` work the same as `lambda`

That is, allow it to generate a `lambda` instead of a `def` statement if the function body is just an expression.

I've removed two uses of with_decorator in hy.compiler because they'd require adding another case to HyASTCompiler.compile_decorate_expression and they have no ultimate effect, anyway.

In a few tests, I've added a meaningless statement in `fn` bodies to force generation of a `def`.

I've removed `test_fn_compiler_empty_function` rather than rewrite it because it seems like a pain to maintain and not very useful.

* Remove `lambda`, now that `fn` does the same thing
2017-02-22 17:36:52 -06:00
Kodi Arfer
45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +02:00
Kodi Arfer
92d5d6b42c Merge pull request #1224 from Kodiologist/refactor-models
Refactor hy.models
2017-02-17 07:42:40 -08:00
Kodi Arfer
0336ff3c68 Don't put redundant names in _stdlib (#1221)
This prevents pointless imports of hy.core, like importing `map` in Python 3.
2017-02-16 21:14:06 -07:00
Kodi Arfer
ace125ee9b Consolidate hy.models.* and tests/models/* into one file apiece
They were a lot of similar, tiny files.
2017-02-16 19:43:00 -08:00
Kodi Arfer
f3edeb99ae Allow commas and underscores in numeric literals
You can use them as thousands separators.

This change differs from PEP 515 in that not only does it allow commas in addition to underscores, but it's much more liberal about placement. Any number of underscores or commas can be placed anywhere, even at the start.
2017-02-15 09:03:24 +02:00
Kodi Arfer
23a7363cce Fix a test for Python 2 2017-02-13 09:12:21 -08:00
Kodi Arfer
31f3a55a26 Remove tests of let 2017-02-13 09:12:13 -08:00
Kodi Arfer
b1df5d1428 Remove extra uses of let in native_tests.language
Tests of `let` itself remain.
2017-02-04 09:18:22 -08:00
Kodi Arfer
d72abb39f1 Remove uses of let from various tests 2017-02-04 09:07:27 -08:00
Kodi Arfer
1abf293793 Test the use of and in shadowed chained comparisons 2017-02-03 15:43:00 -08:00
Kodi Arfer
9ca7f49c88 Make xor return single true inputs
The documentation should now be correct (#1214).
2017-02-03 22:25:38 +02:00
Kodi Arfer
ed930edefe Allow keyword args in method calls before the obj (#1167)
Unlike Python, Hy allows the programmer to intermingle positional and keyword arguments. This change removes an exception to that rule for method calls, in which the method callee always had to be the first thing after the method. Thus, `(.split :sep "o" "foo")` now compiles to `"foo".split(sep="o")` instead of `HyKeyword("sep").split("o", "foo")`.
2017-01-03 00:24:55 -07:00
Jakub Wilk
7aaf5f5330 Fix invalid escape sequences
Fixes:

    hy/cmdline.py:175: DeprecationWarning: invalid escape sequence \_
    tests/lex/test_lex.py:267: DeprecationWarning: invalid escape sequence \s
    tests/compilers/test_compiler.py:45: DeprecationWarning: invalid escape sequence \*

when run against Python 3.6 with warnings enabled.
2017-01-01 00:20:04 +03:00
Kodi Arfer
9449584c7f Merge branch 'contrib-cleanup' 2016-12-30 08:06:59 -08:00
Kodi Arfer
91b26d1fdd Remove contrib.meth
This seems to be specific to Flask, a web framework.
2016-12-29 08:35:54 -08:00
Kodi Arfer
85b4160637 Remove contrib.curry
It's undocumented and of dubious value.
2016-12-29 08:35:54 -08:00
Kodi Arfer
e5c6f733a4 Remove tests for contrib.botsbuildbots
This is an Easter egg whose tests add a dependency (requests) and cause a test failure if you don't have an active Internet connection.
2016-12-29 08:35:54 -08:00
Kodi Arfer
8eceb4fe9d Move contrib.anaphoric to contrib.extra 2016-12-29 08:35:41 -08:00
Kodi Arfer
397fa80380 Revert "Modernized." (#1085) (#1188)
This reverts commit 13b484ce46 and fixes #1183.
2016-12-27 09:09:58 -06:00
Kodi Arfer
d980a4a8ee Remove contrib.alias
I don't see why you'd put this in the standard library. I guess it could be useful for when you're maintaining a library and you want to change the name of a function or macro but keep the old name around for a while so people's code doesn't break immediately. But that's a pretty limited purpose.
2016-12-26 15:39:26 -08:00
Philip Xu
eb8fe0b085 Add test for juxt 2016-12-25 16:57:50 -05:00
Philip Xu
f8a5c151f8 Remove trailing space 2016-12-25 16:56:24 -05:00
Tuukka Turto
71f30e845d Add comp, constantly and complement (#1179)
* Add comp, constantly and complement

relates #1176

* Fix composition order in comp

* comp without parameters returns identity

* Doc edits for comp, complement, constantly

* Test that `(comp)` returns `identity` exactly

* Simplify the `reduce` call in `comp`

* updated version of comp
2016-12-25 13:11:25 -07:00
Kodi Arfer
a4158c5543 Add tests for the empty keyword
I have some macros for using pandas and NumPy that expect : to be a keyword instead of an ordinary symbol. These tests will ensure that we don't break this unless we want to.
2016-12-21 10:19:42 -08:00
Elf M. Sternberg
13b484ce46 Modernized. 2016-12-20 10:54:11 +02:00
Tuukka Turto
e588b4928d add defmacro! and fix macro expansion error message (#1172)
* added defmacro!

* revert #924

#924 had an error and should never have been merged in the first place. (see #903)

* put back import getargspec

Without the `formatargspec` this time.

* Give better error message on failed macro expansion

Better error messages work most of the time. In cases where there are
parameters that aren't valid in Python, error message shown is rather
ugly. But this is better than no error messages at all and such
macros with strange parameter names are rather rare.

* fix flake8 errors

* Minor English improvements
2016-12-14 18:10:46 -06:00