Commit Graph

504 Commits

Author SHA1 Message Date
Paul Tagliamonte
42983d173f Merge branch 'master' into pr/796 2015-04-30 11:14:54 -04:00
Berker Peksag
5f1776fe06 Merge pull request #793 from kirbyfan64/destruct-args
Add argument destructuring
2015-04-30 14:01:47 +03:00
Berker Peksag
d11014d115 Merge pull request #777 from tianon/compare-shadows
Add shadow functions for comparison operators
2015-04-30 13:58:32 +03:00
Zack M. Davis
2ad2d5a418 fix keyword lambda values by retaining statements in Result
As reported in issue #748, there was a bug in which passing a lambda
as the value of a :keyword argument would fail—

$ hy --spy
hy 0.10.1 using CPython(default) 3.4.0 on Linux
=> (sorted (range 10) :key (fn [x] (- x)))
from hy.core.language import range
sorted(range(10), key=_hy_anon_fn_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_fn_1' is not defined

The function call would appear in the generated AST without being
preceded by the appropriate function definition corresponding to the
anonymous function argument value in the Hy source, causing either a
NameError (as in the example above), or erroneous reuse of whatever
function was already pointed to by the `_hy_anon_fn_` name referenced
in the list of keywords passed to `ast.Call`.

This commit aims to fix the problem by handling it in same way that
the expression/statement gap is bridged many other places in the
compiler, by adding the compiled value of the keyword argument to the
Result object being built during `_compile_collect`, with the
understanding that any Python statements implied by the argument value
will be appropriately preserved therein.
2015-04-26 15:57:08 -07:00
Tianon Gravi
ff1c4ccdb3 Add shadow functions for comparison operators 2015-04-24 12:19:23 -06:00
Ryan Gonzalez
4ead84b058 Add argument destructuring 2015-04-18 12:32:03 -05:00
Zack M. Davis
0dbf2126cf adds support for Python 3.5 infix matrix multiplication
Python 3.5 will have a new commercial-at infix operator with the magic
methods __matmul__, __rmatmul__, and __imatmul__, unused as yet in the
standard library, but intended to represent matrix multiplication in
numerical code; see PEP 465 (https://www.python.org/dev/peps/pep-0465/)
for details. This commit (developed against Python 3.5 alpha 3) brings
support for this operator to Hy when running under Python 3.5 (or,
hypothetically as yet, greater). For Hy under Python <= 3.4, attempting
to use `@` in function-call position currently results in a NameError;
this commit does not change that behavior.

This is intended to resolve #668.
2015-04-12 21:45:39 -07:00
Antony Woods
d1ed8f49d3 Re-implemented last function so that it also supports iterators. Added a test to reflect this. 2015-04-07 10:30:52 +01:00
Antony Woods
cbd942fd02 Added (last) function to core language 2015-03-18 15:23:43 +00:00
Nathan Woodrow
a3ad4df6a1 Run file using hy -i
Add test for -i using file
2015-02-28 18:11:42 +10:00
Adrià Garriga-Alonso
f7b5486b69 Assert now may take an optional label, like in Python 2015-02-22 17:34:19 +01:00
Zack M. Davis
0fd6ed052c move imports and operators to satisfy new version of pep8 checker
jcrocholl/pep8 (used by flake8, used in Hy's continuous integration
builds) introduced an imports-at-top-of-file check in 1.6.0 and a
line-breaks-around-binary-operators check in 1.6.2. This commit makes
nonfunctional changes to bring the Hy codebase in compliance with this
tool, fixing #764.
2015-02-16 22:21:49 -08:00
Zhao Shenyang
dafcc7ec70 add symbol? function to hy.core
`symbol?` will test if the input is an instance of HySymbol. It's useful when writing macros.
2015-01-29 23:17:52 +08:00
Matthías Páll Gissurarson
1d5b455491 Added a fix for nested decorators. Fixes #752 2015-01-14 19:42:02 +00:00
Adam Schwalm
f1df108b31 Add support for multi-line strings in interpreter 2014-12-28 23:38:38 -06:00
Christopher Allan Webber
d98e4fd733 Implement keyword argument passing... (foo-func 1 2 :kw1 "bar") works!
This code is heavily, *heavily* based off of Guillermo Vaya
(willyfrog)'s work... instead of defining its own keyword arg though, it
uses the "standard" :kwarg type, which is the main difference from
willyfrog's original branch.

Included tests and some documentation in the tutorial.

Also documented "apply" separately as an example of reproducing
*args and **kwargs.
2014-12-23 14:07:02 -06:00
Berker Peksag
e3aac14cf9 Merge pull request #715 from ALSchwalm/master
Fix error when 'let' context contains a non-symbol non-list
2014-12-18 10:48:51 +02:00
Adam Schwalm
52334c0b62 Fix error when 'let' context contains a non-symbol non-list 2014-12-18 02:15:41 -06:00
Gergely Nagy
6b3c552df4 Better error messages for fn/defn w/o arglists
When (fn) or (defn) does not get an arglist as first/second parameter,
emit a more descriptive error message, rather than an ugly traceback.

Fixes #716.

Reported-by: Joakim Tall
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-12-12 13:28:28 +01:00
Paul Tagliamonte
0dfa9123a2 Merge branch 'master' into pr/705 2014-12-07 14:21:06 -05:00
Bob Tolbert
ffd85bcc3e Fixes a long-standing bug in import under Python 3.3 and later.
Our MetaImporter was being inserted at the end of sys.meta_path.
For Python prior to 3.3, this was fine since sys.meta_path
was empty by default. As of the completion of PEP 302 in Py3.3 and
later, there are several importers registered by default. One of
these was trying (and failing) to import simple Hy modules,
resulting in a failure to import anything inside __init__.hy.

This change simply inserts the Hy-specific importer at the front
of the list.

This was noted in issue #620 (great catch @algernon)
2014-12-07 11:02:48 -07:00
Nathan Woodrow
41806895b2 Add macro expansion in defclass 2014-12-07 11:52:09 +10:00
Bob Tolbert
05574f6ad7 Implement -m command line flag to run a module by name 2014-11-26 09:13:45 -07:00
Christopher Allan Webber
917ba9fce5 Test to ensure exception handling in yield-from works right 2014-11-20 20:48:15 -06:00
Christopher Allan Webber
86d8f69ef7 Fix yield-from test indentation
Indentation was inconsistent with our usual indentation style.
2014-11-20 20:48:15 -06:00
Paul Tagliamonte
602f392fe7 Implement yield-from in Python 2.x as a macro
And who said you can't teach an old dog new tricks.

  ... but at the same time, drop Python 3.2 for not knowing this new
  trick.
2014-11-20 20:48:15 -06:00
Paul Tagliamonte
b92c19c73c Merge branch 'master' into pr/579 2014-11-15 08:02:41 -05:00
Paul Tagliamonte
ec593154fe Merge branch 'master' into pr/637
Conflicts:
	hy/core/language.hy
2014-11-15 07:58:56 -05:00
Paul Tagliamonte
6d25237093 Merge branch 'master' into pr/658 2014-11-15 07:54:24 -05:00
Paul Tagliamonte
6995a5aece Merge branch 'master' into pr/661
Conflicts:
	AUTHORS
2014-11-15 07:49:20 -05:00
Paul Tagliamonte
dcf29d3d2a Fix the test decorator to return the class. 2014-11-15 07:47:55 -05:00
Paul Tagliamonte
408f72ef12 Merge branch 'master' into pr/685 2014-11-15 07:45:29 -05:00
Ryan Gonzalez
c7e4d4cd6e Add tests 2014-11-14 14:21:16 -06:00
Tianon Gravi
96410f506e Add a dedicated lisp-if-not / lif-not macro
This is in parallel to `if` / `if-not` (so not without precedent). :)
2014-11-06 12:44:15 -07:00
Ryan Gonzalez
c88e75251c Fix Travis failures 2014-11-05 21:01:10 -06:00
Abhishek Lekshmanan
1b6c765e97 Merge branch master onto #525
Conflicts:
	hy/core/language.hy
	tests/native_tests/language.hy
2014-10-09 21:28:33 +05:30
bismigalis
76d7e3479a Added merge-with 2014-10-02 18:50:04 +04:00
Ian Denhardt
3503ed9027 Add tests for _wrap_value 2014-09-21 12:08:14 -04:00
Gergely Nagy
3f01ed5014 Add a Botsbuildbots function
A tribute to Portal 2, this function will return an infinite list of the
contents of the AUTHORS file on GitHub master (assuming requests is
installed). Except, the macro does this, the function never gets called,
it is purely there for tribute reasons.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-09-05 12:37:51 +02:00
han semaj
99db02668b Fix 'some' (first logical true value or nil) 2014-09-04 21:29:38 +12:00
Foxboron
66e3cdcb99 Rename slots to attribute/attr 2014-09-04 00:06:52 +02:00
Morten Linderud
bc0ef3ea14 Merge pull request #641 from microamp/issue-638
Fix #638: Make nth return default value when out of bounds
2014-09-03 14:28:01 +02:00
han semaj
c8985a898b Shadow '+' to handle string/list concatenation 2014-08-26 21:38:52 +12:00
han semaj
ecc664337d Make nth return default value when out of bounds 2014-08-23 23:35:31 +12:00
han semaj
23f31d4ac1 Reimplement butlast in terms of drop-last 2014-08-22 21:51:12 +12:00
han semaj
7f5c8e39d8 Implement drop-last 2014-08-22 21:09:59 +12:00
Nicolas Dandrimont
aafb16d69f Merge branch 'master' into pr/584 2014-08-18 18:18:25 +02:00
Paul Tagliamonte
37fc9e08d0 Merge branch 'master' into pr/635 2014-08-18 12:10:08 -04:00
han semaj
3f1a24bfe3 Implement interleave and interpose 2014-08-17 14:53:57 +12:00
Foxboron
c8adf9b726 Renamed stdin -> from-file and removed apply from tests + docs 2014-08-14 18:18:05 +02:00