gilch
e7b21cc0df
fix indent
2018-03-23 14:16:06 -07:00
Kodi Arfer
ad59fd7ff6
In -> and ->>, don't modify the arguments
2018-03-23 13:57:19 -07:00
Simon Gomizelj
c663d38e33
Add metaclass support, support PEP 3115 and PEP 487
2018-03-22 13:28:22 -07:00
Kodi Arfer
4c5dea0756
Use io.StringIO instead of the StringIO module
2018-03-13 14:57:31 -04:00
Kodi Arfer
6875ae0e3f
Replace `hyify` with `unmangle`
2018-03-13 14:56:49 -04:00
Kodi Arfer
3c97d2982c
Use `*1` instead of `_` for REPL history
...
`_`, as a variable, is now the shadow subtraction operator.
2018-03-13 14:56:47 -04:00
Kodi Arfer
85968e70dd
Add `mangle` and `unmangle` as core functions
2018-03-13 14:55:55 -04:00
Kodi Arfer
0c8c5dc830
Mangle special forms
2018-03-13 14:55:55 -04:00
Kodi Arfer
ccb3ba6092
Mangle macro names
2018-03-13 14:55:55 -04:00
Kodi Arfer
0c816f2e83
Mangle keyword arguments
2018-03-13 14:55:55 -04:00
Kodi Arfer
d252bb0e94
Mangle names that coincide with Python keywords
2018-03-13 14:55:55 -04:00
Kodi Arfer
52edad28e2
Overhaul mangling rules
2018-03-13 14:55:53 -04:00
Kodi Arfer
d501d4d806
Mangle symbols at compile-time instead of parse-time
...
This means that a HySymbol remembers its original name. That is, `a-b` and `a_b` are different symbols although `(setv a-b 1)` and `(setv a_b 1)` set the same variable (namely, `a_b`).
Most of the edits in this commit are to switch underscores to hyphens in places where mangling hasn't happened yet.
I removed some lexer tests since the lexer no longer does any mangling.
2018-03-13 14:55:15 -04:00
Kodi Arfer
7fcc7ac4b6
Make unary comparison ops evaluate their argument
2018-03-13 14:38:36 -04:00
Kodi Arfer
0574e275b5
Make hy-repr support some `collections` classes
2018-03-10 18:11:07 -08:00
Kodi Arfer
38f461890d
Make hy-repr support DateTime objects
2018-03-10 18:11:07 -08:00
Kodi Arfer
3dbe05302e
Make hy-repr support regex match objects
2018-03-10 18:11:07 -08:00
Kodi Arfer
f7ab9a6e7c
Make hy-repr support dictionary views
2018-03-10 18:11:07 -08:00
Kodi Arfer
90a09b5b44
Make hy-repr use double spaces for dictionaries
2018-03-10 18:11:07 -08:00
Kodi Arfer
83c4f63bc2
Reimplement hy-repr with registered functions
...
This removes a lot of hy-reprs that were hard-coded into the hy-repr function itself. It also allows you to add a hy-repr for an existing class without monkey-patching the class.
2018-03-10 18:11:07 -08:00
Simon Gomizelj
ef2f435647
Add a hy.introspect module to deal with getargspec deprecation
2018-02-14 16:05:31 -05:00
Simon Gomizelj
be6ddd4bb2
Fix deprecation warning triggered by PEP 479
2018-02-14 16:05:31 -05:00
Simon Gomizelj
316220b742
Fix AST generation of a naked return
2018-02-14 16:05:31 -05:00
Kodi Arfer
7cf23fabc4
Merge pull request #1503 from vodik/travis-py37
...
Add python 3.7-dev to travis, allow it to fail
2018-02-14 08:41:14 -08:00
Simon Gomizelj
a2c8f50b30
Implement changes to support PEP 552
2018-02-09 16:43:25 -05:00
Simon Gomizelj
5c40f793a1
Support PEP 328
...
Add support for proper relative imports
2018-02-06 23:41:12 -05:00
Tuukka Turto
5c720c0110
Merge pull request #1473 from Kodiologist/new-year-2018
...
Update copyright years
2018-02-05 15:11:59 +02:00
Tuukka Turto
cf87de5cc2
Merge pull request #1483 from vodik/remove-def
...
Just remove `def`
2018-01-31 08:54:59 +02:00
Simon Gomizelj
0cd4df3898
Remove def and standardize on setv
2018-01-21 00:25:33 -05:00
Tuukka Turto
a9621817f9
Merge pull request #1433 from Kodiologist/while-multistatement
...
Handle statements in the condition of `while`
2018-01-11 07:45:27 +02:00
Kodi Arfer
64cf7c7437
Merge pull request #1456 from Kodiologist/big-floats
...
Don't parse large floats as symbols
2018-01-11 00:44:50 -05:00
Kodi Arfer
6de7ddfee5
Update copyright years
2018-01-01 10:38:33 -05:00
Simon Gomizelj
f69ccd2421
Allow coroutines to be decorated
2017-12-31 09:03:39 -05:00
Kodi Arfer
b81585eaba
Reimplement _with and _for as functions
2017-12-30 19:39:15 -05:00
Simon Gomizelj
1e4ad3167b
Introduce for/a* and for/a expressions
2017-12-30 19:02:15 -05:00
Simon Gomizelj
783d53ecb7
Introduce with/a* and with/a expressions
2017-12-30 19:02:15 -05:00
Simon Gomizelj
2ffaa8e5be
Fix yield-from to prevent it from accepting no arguments
...
Closes #1472
2017-12-30 19:02:15 -05:00
Simon Gomizelj
e3e01d4405
Introduce fn/a and defn/a
...
Closes #1054
2017-12-30 19:02:15 -05:00
Jakub Wilk
8b986e87e3
Add missing space between words
2017-12-24 20:02:23 +01:00
Rob Day
eda78eb81c
Allow multiple expressions in a try
2017-12-03 09:47:41 +00:00
Jakub Wilk
e2e1b04ea3
Fix typos
2017-11-26 00:44:03 +01:00
Kodi Arfer
a26480a81b
Don't parse large floats as symbols
2017-11-11 15:14:28 -08:00
Kodi Arfer
52a0c8a870
Unify implementations of `eval-X-compile`
2017-11-02 08:43:43 -07:00
Kodi Arfer
fd64575799
Handle statements in the condition of `while`
2017-11-02 07:31:58 -07:00
Ryan Gonzalez
e0e664c030
Merge branch 'master' into letmacro
2017-11-01 09:39:18 -05:00
Kodi Arfer
a074bb9a5c
Work around an astor regression for NaN
2017-10-31 17:50:44 -07:00
gilch
6bb997dbea
update astor to 0.6
2017-10-31 14:13:41 -06:00
gilch
91bdaea535
add documentation macros
2017-10-30 21:25:25 -06:00
gilch
a4dd344ebd
protect eval-and-compile/eval-when-compile in let
2017-10-30 20:24:09 -06:00
gilch
82b4518fa6
error check defclass name
2017-10-30 20:24:09 -06:00
gilch
e90f082baf
back `let` with dict for better defclass behavior
2017-10-30 20:23:57 -06:00
gilch
3707681056
make deftag/defmacro macros, not special forms
2017-10-29 17:52:40 -06:00
Tuukka Turto
fac87c99d0
Merge pull request #1444 from gilch/xi-tag
...
change xi macro to #% tag macro
2017-10-29 21:34:56 +02:00
Tuukka Turto
268463c68d
Merge pull request #1432 from Kodiologist/else-detection
...
Don't treat [else…] or ("else"…) as else clauses
2017-10-29 21:21:32 +02:00
Tuukka Turto
fabc55a62a
Merge pull request #1431 from Kodiologist/repl-crash
...
Fix a crash in HyTypeError.__str__
2017-10-29 21:20:00 +02:00
gilch
497e929913
generalize #% to arbitrary expressions
2017-10-26 14:23:25 -06:00
gilch
b5f1136ba5
%* %** parameters for #% tag macro
2017-10-26 13:03:01 -06:00
gilch
f81fb771eb
change xi macro to #% tag macro
2017-10-26 12:55:48 -06:00
gilch
2319adcc7f
fix whitespace in anaphoric
2017-10-26 12:53:08 -06:00
ekaschalk
38375c6bf7
Standardize hy.core docstrings
2017-10-17 13:20:26 -07:00
gilch
c4b3d7bcda
fix gensym format to start with _ for import *
2017-09-23 23:41:37 -06:00
gilch
a54f6aa38b
add hidden &name parameter to macros
...
The module name allows macros to preexpand their body in the proper
context.
2017-09-23 14:59:43 -06:00
gilch
5bbf4d9894
fix premature binding in `let`
2017-09-22 20:07:48 -06:00
Kodi Arfer
1e456c6ced
Don't treat [else…] or ("else"…) as else clauses
2017-09-20 16:34:56 -07:00
Kodi Arfer
39785b4657
Fix a crash in HyTypeError.__str__
2017-09-20 10:40:52 -07:00
gilch
081a6e2575
factor out smacrolet from let
2017-09-18 23:01:13 -06:00
gilch
bcc93fb1fe
refactor let symbol expansion to a class
2017-09-18 21:01:42 -06:00
gilch
20b4342d40
support (global) in `let`
2017-09-18 14:54:08 -06:00
gilch
ba898aa8d8
support (nonlocal) in `let`
2017-09-18 13:51:32 -06:00
gilch
34038ff433
implement `let`
2017-09-18 12:21:42 -06:00
Ryan Gonzalez
db210929d0
Merge pull request #1360 from gilch/model-repr
...
proper reprs for Hy models
2017-09-18 08:45:28 -05:00
gilch
d38956fb9e
remove trailing commas in HyDict reprs
2017-09-18 01:03:00 -06:00
Rob Day
907e72681f
Let argument destructuring work with docstrings
2017-09-17 21:06:45 +01:00
Rob Day
5a6488e353
Treat _42 etc. as a variable name, not an integer
2017-09-16 16:12:29 -07:00
gilch
e43d6f5e2f
Merge pull request #1419 from rkday/else_multiple_statements
...
Allow multiple statements in the else branch of for
2017-09-16 14:10:28 -06:00
Rob Day
be35b09e5d
Allow multiple statements in the else branch of a for loop
2017-09-16 20:41:22 +01:00
Ryan Gonzalez
3f69ed8e8e
Merge pull request #1399 from Kodiologist/compiler-refactor
2017-09-15 14:44:32 -05:00
Ryan Gonzalez
44e5ded522
Merge pull request #1379 from Kodiologist/lua-str-literal
...
Add #[DELIM[ … ]DELIM] syntax for string literals
2017-09-15 14:36:08 -05:00
Rob Day
567fa14f1d
Allow else after a while loop
2017-09-14 20:55:29 +01:00
Kodi Arfer
957a721cd4
Remove _hy_anon_fn_N in favor of _hy_anon_var_N
2017-09-13 13:30:59 -07:00
Kodi Arfer
cf7ff802c9
Make hy.compiler.builds more flexible
...
I removed the "Hypster" error message and the test for it because it can only catch compiler bugs that should themselves be caught by Hy's tests.
2017-09-13 13:30:59 -07:00
Kodi Arfer
e30abcd20f
Combine some literal compilation methods
2017-09-13 13:30:59 -07:00
Kodi Arfer
5f36a53577
General compiler refactoring pass
...
Most of the changes are to use the new `asty` shorthand, but I also combined methods and statements when I saw obvious duplication.
2017-09-13 13:30:59 -07:00
Kodi Arfer
ddded5e8bd
PEP8 fixes in compiler
2017-09-13 13:30:59 -07:00
Kodi Arfer
deb801edab
Preserve .brackets in quoted HyStrings
2017-09-08 11:27:34 -07:00
Kodi Arfer
eb23ddc1e2
Add #[DELIM[ … ]DELIM] syntax for string literals
2017-09-08 11:27:34 -07:00
gilch
2d8a318e0c
color compound hy model reprs
2017-09-07 11:50:22 -07:00
gilch
021204af13
make HyCons __repr__ iterative
2017-09-07 11:50:22 -07:00
gilch
860431b2a5
make HyCons repr indented and multi-line
2017-09-07 11:50:22 -07:00
gilch
7674bf3267
proper reprs for Hy models
2017-09-07 11:50:16 -07:00
gilch
20516cce79
make native tests run on Windows too
2017-09-05 13:35:28 -06:00
Ryan Gonzalez
c69f8ebb79
Merge pull request #1404 from Kodiologist/unicode_literals
...
Simplify string parsing with `unicode_literals`
2017-08-29 18:22:02 -05:00
Kodi Arfer
e3e7fa8ce6
Catch exceptions raised by HyREPL.output_fn
2017-08-29 14:54:26 -07:00
Kodi Arfer
98fb33d0a3
Simplify string parsing with `unicode_literals`
...
I switched from `ast.literal_eval` back to `eval` because the former doesn't respect `unicode_literals`.
2017-08-28 10:28:19 -07:00
Kodi Arfer
0fc96306bc
Drop support for Python 3.3
2017-08-26 13:36:51 -07:00
Kodi Arfer
7ed31a18f3
Forbid arguments to `break` and `continue`
2017-08-26 11:37:15 -07:00
Kodi Arfer
2bbf886ceb
Make `assoc` a macro instead of a special form
...
The new macro evaluates its lvalue only once.
2017-08-25 11:41:28 -07:00
Ryan Gonzalez
dea99c8b76
Merge pull request #1354 from gilch/comment-discard
...
add #_ discard syntax
2017-08-19 11:29:57 -05:00
Kodi Arfer
8d40a68232
Initialize the return variable of `with`
2017-08-19 07:35:41 -07:00
Kodi Arfer
2ef9bc75d4
Clean up `with`
2017-08-19 07:25:00 -07:00
Kodi Arfer
21ea36f277
Add `return` as a special form
2017-08-11 13:56:44 -07:00
Kodi Arfer
cca8beea44
Fix the grammar of an error message
2017-08-11 10:49:32 -07:00
David Schaefer
969fa8d533
Fixes #1350 : try form in defmacro
2017-08-11 01:21:01 +02:00
David Schaefer
274f5e9002
Fix copy behaviour of HyComplex
2017-08-09 23:30:16 +02:00
Andrew Silva
c4f183f97c
Added docomplete truth check on hy/completer.py:27
...
Without the check, the next line will reference readline even if the
library was not successfully loaded.
2017-08-07 13:25:58 -04:00
Jordan Danford
c67b8bccb9
Expose `read`, `read_str`, and `eval` in Python
...
- Expose `read`, `read_str`, and `eval` in Python
- Add string evaluation example to interop section of docs
- Add test for `eval`
- Explain `eof` keyword argument in `read` docstring
2017-08-05 17:29:15 -07:00
David Schaefer
432d560310
No TypeError from multi-arity defn returning None
2017-08-04 17:08:41 +02:00
gilch
d0530b0e7e
add comment macro
2017-08-03 19:05:38 -06:00
Kodi Arfer
e8ffd41202
Merge pull request #1349 from woodrush/fix-unquote-splice-none
...
Allow `unquote-splice` to accept any false value as empty
2017-08-02 19:50:47 -04:00
gilch
203965d0fa
add #_ discard syntax
2017-08-02 16:55:14 -06:00
Kodi Arfer
ecc974de1e
Implement Python 2 `exec`
...
The implementation of `hy.core.language.exec` draws code from the `exec_` function in commit f574c7be6ebc80041ef58ca29588f310248ebed4 of the library Six, which is copyright 2010–2017 Benjamin Peterson and licensed under the Expat license.
2017-08-02 13:33:59 -04:00
Hikaru Ikuta
a0224ef8bd
Allow `unquote-splice` to accept any false value as empty
2017-08-02 00:50:37 +09:00
Kodi Arfer
2d20a52379
Don't use `cond` in the definition of a core macro
...
`cond` itself is a core macro.
2017-07-28 16:58:45 -07:00
gilch
d9a5acbcc9
Merge pull request #1343 from Kodiologist/repl-history-after-exception
...
Save REPL history after an exception
2017-07-26 22:39:30 -06:00
Kodi Arfer
67a4815024
Shadow `get` ( #1344 )
2017-07-26 21:10:54 -05:00
Kodi Arfer
2f340f8049
Save REPL history after an exception
2017-07-26 14:26:45 -07:00
gilch
0a14410911
Merge pull request #1337 from Kodiologist/shetag
...
Don't try to lex tag-macro calls as shebangs
2017-07-25 12:43:53 -06:00
Kodi Arfer
28ce83524b
Don't try to lex tag-macro calls as shebangs
2017-07-23 11:43:19 -07:00
Kodi Arfer
eea8cf1061
hy-repr: Fix a crash when given a NumPy array
2017-07-20 08:46:42 -07:00
Kodi Arfer
7b94c45e16
Remove an extra parenthesis in hy.contrib.profile
2017-07-20 08:46:37 -07:00
Kodi Arfer
0bbb5f8e34
hy-repr: Support #* and #**
2017-07-19 10:25:24 -07:00
Kodi Arfer
784a44601b
Remove the implementation of `apply`
2017-07-19 10:18:55 -07:00
Kodi Arfer
75e4ad8304
Remove uses of `apply` from /hy
2017-07-17 13:34:42 -07:00
Kodi Arfer
2d863abc85
Implement #* and #** unpacking
2017-07-17 13:34:39 -07:00
Kodi Arfer
801836f6c2
Remove the Python 2 yield-from macro
...
I moved the yield-from tests from native_macros to py3_only_tests.
2017-07-13 08:46:41 -07:00
Kodi Arfer
a979dd85f7
Don't make `yield-from` a special form on Python 2
2017-07-13 08:46:41 -07:00
Tuukka Turto
678998f00c
Merge pull request #1321 from Kodiologist/no-str-as-sym
...
Require HySymbols instead of HyStrings in more cases
2017-07-12 22:11:36 +03:00
Ryan Gonzalez
467b300e6c
Remove an outdated comment
2017-07-12 13:56:17 -05:00
Kodi Arfer
b7657e8fa3
Require HySymbols instead of HyStrings more often
2017-07-12 10:57:35 -07:00
Kodi Arfer
5a1e6a7c6a
hy-repr: Support NaN and Inf
2017-07-10 08:50:49 -07:00
Kodi Arfer
bb91b57dca
Require capitalizing NaN and Inf like so
2017-07-10 08:50:49 -07:00
Kodi Arfer
850ba03d1f
Slightly simplify HyREPL
2017-07-03 17:01:12 -07:00
Kodi Arfer
6db3da779e
Don't wrap values while expanding macros
...
This is the compiler's job now.
2017-07-03 17:01:12 -07:00
Kodi Arfer
55986b2033
Auto-promote values to HyObjects in the compiler
2017-07-03 17:01:12 -07:00
Kodi Arfer
4be37b358b
Make lists no longer magical for the compiler
2017-07-03 17:01:12 -07:00
Kodi Arfer
f55fcf43bd
Add a docstring for hy-eval
...
It's just a copy of the documentation for hy.core.langauge.eval.
2017-07-03 17:01:12 -07:00
Kodi Arfer
ca95194240
Change `eval` from a special form to a function
2017-06-27 08:14:29 -06:00
Kodi Arfer
f2278cf2f0
Support PYTHONDONTWRITEBYTECODE
2017-06-26 19:00:08 -06:00
Kodi Arfer
26d1b3f72e
Don't parse 5.attr or :foo.attr as symbols
2017-06-23 08:30:37 -07:00
gilch
6cd3201421
rename sharp macros to tag macros
2017-06-22 22:48:46 -06:00
gilch
20c26a52e4
make sharp macros take arbitrary identifiers
...
Previously, only a single character was allowed.
2017-06-22 22:46:24 -06:00
neil-lindquist
d3df17d9d8
Modify cond to support single argument branches
2017-06-10 08:30:53 -07:00
Kodi Arfer
5bf9ecfc5a
Forbid (try) and (try BODY)
2017-05-25 20:48:09 -05:00
Kodi Arfer
dffa2811e6
Return from the `else` clause of a `try` form
...
I overhauled the documentation of `try` while I was editing it.
2017-05-25 20:48:09 -05:00
Kodi Arfer
81d89c9d12
Enforce the standard order of `try` elements
2017-05-25 20:48:09 -05:00
Kodi Arfer
0d2749d5cd
Minor cleanup in hy.compiler: try, except
2017-05-25 20:48:09 -05:00
Kodi Arfer
2eb81864df
Make all files comply with license-header policy
2017-04-27 14:16:57 -07:00
Kodi Arfer
d3fa375052
Migrate from Nose to pytest
2017-04-26 14:00:11 -07:00
Kodi Arfer
ec0902b649
Set __file__ of bytecode imports
2017-04-25 09:30:13 -07:00
Kodi Arfer
a27d737e1c
Drop support for Pythons 3 older than 3.3
2017-04-24 14:22:13 -07:00
Kodi Arfer
5aaa7d92d8
Shorten hy._compat
2017-04-24 14:18:56 -07:00
Kodi Arfer
ef3bad7e03
Drop support for Python 2.6
2017-04-24 14:18:56 -07:00
Kodi Arfer
4c38e2c9dd
Rename reader macros to "sharp macros" ( #1282 )
...
They're not actually reader macros, since their arguments are parsed s-expressions, like a regular macro, not pre-parsed source text.
2017-04-21 10:07:48 -05:00
Kodi Arfer
ad94343e4a
Merge pull request #1269 from Kodiologist/bytecode
...
Automatically read and write bytecode
2017-04-14 13:52:07 -07:00
Kodi Arfer
a87b23b4e8
Check the magic number of bytecode files
2017-04-14 13:38:38 -07:00
Kodi Arfer
36324e9499
Work around a Nose import bug on PyPy
2017-04-14 13:38:38 -07:00
Kodi Arfer
2b11b9be20
Automatically read and write bytecode
...
Importing or executing a Hy file now loads the byte-compiled version if it exists and is up to date, and if not, the source is byte-compiled after it's parsed.
This change can speed up Hy a lot. Here are some examples comparing run times of the current master (491b474e
) to this commit, on my laptop with Python 3.6:
- `nosetests --exclude='test_bin'` goes from 3.8 s to 0.7 s (a 5-fold speedup)
- `hy -c '(print "hello world")` goes from 0.47 s to 0.20 s (a 2-fold speedup)
- Rogue TV's startup goes from 3.6 s to 0.4 s (a 9-fold speedup)
Accompanying changes include:
- `setup.py` now creates and installs bytecode for `hy.core`, `hy.contrib`, and `hy.extra`.
- The `hyc` command under Python 3 now creates bytecode in `__pycache__`, as usual for Python 3, instead of putting the `.pyc` right next to the source file like Python 2 does.
I've removed a test of `hy.extra.anaphoric.a-if` that triggers #1268 when the test file is byte-compiled and then hits some weird `macroexpand` bug or something when I try to work around that—Nose crashes when trying to produce an error message, and I can't seem to replicate the bug without Nose.
2017-04-14 13:38:33 -07:00
Kodi Arfer
b71962bbaa
Remove unused internal fn import_file_to_globals
2017-04-14 11:15:58 -07:00
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
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
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
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
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
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
62e5d8e3e3
In hy.models, factor out strip_digit_separators
2017-02-16 19:43:16 -08:00
Kodi Arfer
bebcbbeba6
Change KEYWORD_PREFIX to HyKeyword.PREFIX
2017-02-16 19:43:16 -08: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
9f4b630e14
Fix Python 2 issue in take-nth
...
It was trying to `return` a value in a generator, which Python 2 forbids.
2017-02-13 09:12:21 -08:00
Kodi Arfer
2a44928eb7
Remove `let`
...
Yes, bizarrely, this does require editing the implementation of `defn` a little. Without the import, HyList isn't in scope. Defining `let` made it visible due to black magic regarding automatic import.
2017-02-13 09:12:21 -08:00
Kodi Arfer
99638ba2df
Remove uses of `let` from /hy
2017-02-03 17:06:26 -08:00
Simon Whalen
b89d142e95
Use `and` in hy.core.shadow.comp_op
...
Makes shadow operator behavior match normal (Python) operator behavior
when said operators are used in chained comparisons.
Resolves #1191
2017-02-03 15:22:19 -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
407a79591a
Remove contrib.flow
...
It's not tested, and sure enough, a glance at the code suggests that `case` and `switch` will evaluate their first argument once for every clause, which is unlikely to be desirable. I say remove it, but if anybody wants to fix and test and re-add `case` (and change it to a square-bracket syntax like `cond`), be my guest.
2016-12-29 08:35:54 -08:00
Kodi Arfer
38d11bd455
Translate MultiDispatch from Python to Hy
...
Now we can put it into contrib.multi instead of its own module.
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
8eceb4fe9d
Move contrib.anaphoric to contrib.extra
2016-12-29 08:35:41 -08:00
Kodi Arfer
bc4d67891d
Merge pull request #1190 from pyx/docstring
...
Improve integer? and juxt docstrings
2016-12-27 09:05:48 -08:00
Kodi Arfer
397fa80380
Revert "Modernized." ( #1085 ) ( #1188 )
...
This reverts commit 13b484ce46
and fixes #1183 .
2016-12-27 09:09:58 -06:00
Philip Xu
bacfa5d9eb
Upgrade juxt docstring to match documentation
2016-12-27 02:45:09 -05:00
Philip Xu
c9b40037d5
Fix typo
2016-12-27 02:41:16 -05:00
Kodi Arfer
670c5ae7e5
Add hy.extra
2016-12-26 15:39:26 -08: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
2e87284987
Add juxt
2016-12-25 16:54:53 -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
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
Kodi Arfer
55301884a4
Allow hy2py to use standard input instead of a file ( #1163 )
...
Fixes #1160 .
2016-12-13 20:30:12 +02:00
Kodi Arfer
5b85990d87
Add a module for getting reserved words ( #1171 )
...
This is helpful for writing syntax highlighters (e.g., https://github.com/hylang/hy/pull/1170 ).
2016-12-12 10:11:42 +02:00
Kodi Arfer
b3d7069fb3
Merge branch 'seq'
2016-12-08 10:27:33 -08:00
Kodi Arfer
d2342cb69d
Minor cleanup in sequences.hy
2016-12-07 16:32:37 -08:00
Kodi Arfer
e86222c93f
Allow calling `defseq` without `require`ing `seq`
2016-12-07 16:21:17 -08:00
Kodi Arfer
6bf5ebd8ee
Remove some trailing spaces
2016-12-07 16:17:52 -08:00
Ryan Gonzalez
2c9a224bd6
Merge pull request #1050 from tuturto/multimethod
...
Modify multimethods to use dispatching function
2016-12-07 17:20:04 -06:00
Ryan Gonzalez
5b879323aa
Lvalue of setv is checked too early when using `or`
...
Fix #1151
2016-12-01 09:49:51 +02:00
Tuukka Turto
4219faf532
Update true, false -> True, False
2016-11-30 23:45:21 +02:00
Tuukka Turto
269218a8fd
Merge branch 'master' into seq
2016-11-30 23:41:01 +02:00
Ryan Gonzalez
24ebbc611e
Give an error on empty attributes ( #1138 )
...
Give an error on empty attributes
closes #1137
2016-11-30 07:00:48 +02:00
Tuukka Turto
00615cef36
Add arity-overloaded defn
...
Old defmulti has been renamed to defn and extended to detect when it is
used to define regular function and when a arity-overloaded one.
2016-11-29 16:21:31 +02:00
Tuukka Turto
75c0080cee
Change nil to None
2016-11-29 07:18:30 +02:00
Tuukka Turto
aeab485a4f
Merge branch 'master' into multimethod
2016-11-29 07:14:54 +02:00
Kodi Arfer
ed8e37da62
Burninate the synonyms `true`, `false`, and `nil`
...
Per the straw poll in #908 , as an alternative to #1147 .
Now you must use `True`, `False`, and `None`, as in Python. Or just assign `true` to `True`, etc.; the old synonyms aren't reserved words anymore.
2016-11-23 18:35:17 -08:00
Tuukka Turto
a7f6d1d3f7
Add support for multiple statements in sequences
2016-11-09 08:52:18 +02:00
Tuukka Turto
241d554b0b
Add lazy sequences into contrib
2016-11-08 21:23:49 +02:00
Kodi Arfer
2242097b6b
Translate (.a.b.c x) to x.a.b.c(). ( #1105 )
...
Translate (.a.b.c x) to x.a.b.c().
This is useful for, e.g., calling the Series.str.lower method in pandas.
2016-11-07 19:45:25 +02:00
Tuukka Turto
77bc767907
Merge branch 'master' into multimethod
...
Conflicts:
docs/contrib/multi.rst
2016-11-03 14:06:13 +02:00
Tuukka Turto
f60ed24c29
Add docs and tests for as-> macro ( #1141 )
...
Add docs and tests for as-> macro
Closes #1047
2016-11-03 10:20:26 +02:00
Kodi Arfer
14fddbe6c3
Give `require` the same features as `import` ( #1142 )
...
Give `require` the same features as `import`
You can now do (require foo), (require [foo [a b c]]), (require [foo [*]]), and (require [foo :as bar]). The first and last forms get you macros named foo.a, foo.b, etc. or bar.a, bar.b, etc., respectively. The second form only gets the macros in the list.
Implements #1118 and perhaps partly addresses #277 .
N.B. The new meaning of (require foo) will cause all existing code that uses macros to break. Simply replace these forms with (require [foo [*]]) to get your code working again.
There's a bit of a hack involved in the forms (require foo) or (require [foo :as bar]). When you call (foo.a ...) or (bar.a ...), Hy doesn't actually look inside modules. Instead, these (require ...) forms give the macros names that have periods in them, which happens to work fine with the way Hy finds and interprets macro calls.
* Make `require` syntax stricter and add tests
* Update documentation for `require`
* Documentation wording improvements
* Allow :as in `require` name lists
2016-11-03 09:35:58 +02:00
Tuukka Turto
0abc218ae0
Merge branch 'master' into pr/1135
2016-10-25 15:10:21 +03:00
Tuukka Turto
d969ed63d6
Merge branch 'master' into pr/1081
2016-10-20 19:23:57 +03:00
Tuukka Turto
1459eea697
Merge branch 'master' into pr/1048
2016-10-20 19:19:21 +03:00
Tuukka Turto
9ee9f3a55a
Merge branch 'master' into pr/1131
2016-10-20 19:12:33 +03:00
Kodi Arfer
23c457cee5
Generate hy.version using `git describe`
2016-10-12 17:11:44 -07:00
Kodi Arfer
4b0296d257
Don't check the type of arguments to `inc`, `odd?`, etc.
...
This allows them to be used with numeric types that aren't built in, such as NumPy arrays. Because Python uses duck typing, there's generally no way to know in advance whether a given value will accept a given operator. Of course, things like `(inc "hello")` will still raise a `TypeError`, because so does `(+ "hello" 1)`.
2016-10-11 14:04:50 -07:00
Kodi Arfer
108537a4e0
Allow &rest after &optional, like Python
2016-10-11 13:31:22 -07:00
Kodi Arfer
a33f80b2ce
Allow --version as a synonym for -v
...
--version is a GNU standard that is also common for non-GNU programs, such as Python.
2016-09-29 09:18:04 -07:00
Kodi Arfer
0880610401
Don't sort or deduplicate the items in a HySet
...
Fixes #1120 .
I also added hy.models._wrapper[set] so a macro can return an ordinary set in place of a HySet.
2016-09-26 09:47:04 -07:00
gilch
f8fc1fb71b
Merge pull request #1113 from zackmdavis/travis_by_night
...
nightly Python on Travis CI??
2016-09-24 11:48:47 -06:00
Zack M. Davis
53353c58f2
fix Hy on recent Pythons
...
In issue #1111 , @tianon reported that Hy didn't work with Python
3.6.0b1: trying to evaluate a simple expression at the REPL blew up with
`TypeError: required field "is_async" missing from comprehension`. This
was due to a grammar
change (https://www.python.org/dev/peps/pep-0530/#grammar-updates ) in
the implementation (https://hg.python.org/cpython/rev/cf91a929b81a ) of
PEP 530, which we can easily accomodate.
2016-09-21 22:05:53 -07:00
Kodi Arfer
a60b749d3e
Make unary + call __pos__
...
Fixes #1109 .
__pos__ doesn't work on strings, lists, or tuples, so I've removed some tests that required (= (+ "a") "a") etc.
2016-09-20 13:05:52 -07:00
Matthew Egan Odendahl
3e0d2ac08a
Merge pull request #960 from kirbyfan64/kwonly_err
...
Give an error when &kwonly, &key or &kwargs is used in a macro definition
2016-07-07 10:43:05 -06:00
Ryan Gonzalez
d384580de1
Disallow &key in macros
2016-07-07 11:24:04 -05:00
Vinh Tu
6dc12dd703
Add import_file_to_globals for use in emacs inferior lisp mode
2016-07-01 23:27:36 +01:00
Jakub Wilk
ff4ba5b103
Fix typos
2016-07-01 16:44:12 +02:00
Matthew Egan Odendahl
e0ecaca315
Clarify as-> docstring
2016-06-19 21:14:16 -06:00
Tuukka Turto
0ef9e9ef3b
Modify multimethods to use dispatching function
2016-04-16 13:43:13 +03:00
Matthew Egan Odendahl
7e13bb4e5f
add as-> macro
2016-04-15 20:33:42 -06:00
Ryan Gonzalez
a0251a25ed
Merge pull request #1003 from algernon/f/defreader-1-string
...
defreader: Allow strings as macro names
2016-04-14 12:13:00 -05:00
Matthew Egan Odendahl
eba8e0771a
Merge pull request #1015 from kirbyfan64/pypy_lineno
...
Remove PyPy line number hack (closes #977 )
2016-04-13 12:53:16 -06:00
Ryan Gonzalez
6e66edd7a0
Remove PyPy line number hack ( closes #977 )
2016-04-11 11:18:46 -05:00
timmartin
9d6e04fab0
Keyword arguments to functions are required to be strings ( #1023 )
...
See discussion in #961
2016-04-11 18:38:13 +03:00