Commit Graph

496 Commits

Author SHA1 Message Date
nicolas-p
3d667c179c Tests for ap-pipe and ap-compose
Added tests for the ap-pipe and ap-compose anaphoric macros.
2015-04-26 18:19:01 +02: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
Foxboron
f7675c829e Added read and tests 2014-08-12 18:37:46 +02:00
Bob Tolbert
16e908d56e In order to fix #608, we need to know which symbols can't be assigned.
Python has the keyword.iskeyword method we can leverage for Python
keywords, but we also need to address Hy builtins like 'get' or
'slice'.

And to make behavior compatible with Python 2 or 3, we also make
a special case to prevent assignment to False, True or None as
well as the Hy versions: false, true, null, and nil.

For non-Hy modules, we also check to make sure the symbol is not
part of the compiler. This allows shadow.hy to override "+" but
prevents general use from re-defn-ing 'get' or 'do'.
2014-06-30 21:09:59 -06:00
Tuukka Turto
f3ecb96119 Merge branch 'master' into pr/593 2014-06-24 23:23:48 +03:00
Bob Tolbert
483c6b2576 Merge pull request #602 from agentultra/shadow-builtins
Add shadow.hy to core
2014-06-24 08:57:50 -06:00
J Kenneth King
7f350cdc62 Merge pull request #601 from theanalyst/fix/ap-first
anaphoric: fix first & last when predicates fail
2014-06-23 15:32:29 -04:00
Bob Tolbert
ea5eba5916 Second part of the fix for yield inside a try-finally
As noted in #600, Python 3 allows a return inside a generator
method, that raises a StopIteration and passes the return value
inside the 'value' attr of the exception.

To allow this behaviour we simple set 'contains_yield' while compiling
'yield', thus allowing a return statement, but only for Python 3. Then
when compiling the try-except, we check for contains_yield to decide
whether there will be a return.

This allows code like:

(defn gen []
  (yield 3)
  "goodbye")

to compile in both Py2 and Py3. The return value is simply ignored in
Python 2.

hy2py in Python 2 gives:

def g():
    yield 3L
    u'goodbye'

while hy2py in Python 3 gives:

def g():
    yield 3
    return 'goodbye'

Turns out return in yield started in Python 3.3
2014-06-22 14:59:29 -06:00
Allison Kaptur
b56a03750f revert yield-from test
Yield-from was introduced in 3.3, so we have to catch the compile error that's raise in 3.2. :(
2014-06-09 16:33:32 -04:00
James King
277028cdd5 Remove HyLambdaListKeyword from the parser
It's not a syntactic element and doesn't belong in the parser. Parsing
lambda lists is now handled by the compiler alone.
2014-06-03 21:36:49 -04:00