Commit Graph

712 Commits

Author SHA1 Message Date
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
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
Paul Tagliamonte
911424b359 Merge branch 'master' into pr/628 2014-08-18 11:29:19 -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
Abhishek L
d5668403ae Typo fix s/reprsntation/representation 2014-08-12 23:44:35 +05:30
Foxboron
f7675c829e Added read and tests 2014-08-12 18:37:46 +02:00
han semaj
2628653380 Remove 'remove' (duplicate of 'filterfalse') 2014-07-21 23:07:59 +12:00
han semaj
f94381b7e3 Export filterfalse/input/zip_longest 2014-07-21 23:01:18 +12: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
Tuukka Turto
87e65b7ffe Merge branch 'master' into pr/616 2014-06-24 23:05:29 +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
Bob Tolbert
bd661a3ae8 Fix hy2py output on Windows/Python 3
If there are Unicode symbols in the hy2py output (as in
tests/native_test/language.hy) and the user is on Windows, and
the user is using Python3 and the user doesn't have an appropriate
codepage in the terminal for Unicode, then hy2py will fail at
encoding the output.

This fix makes sure that if encoding fails, the bytes output is shown
instead of throwing an exception and failing completely.  This also
allows the hy2py tests to pass on Windows.

If the user does activate an appropriate codepage, for example,

chcp 65001

then the Unicode output will show correctly.

Converted printing code to small function to eliminate some duplicate code
2014-06-23 14:51:02 -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
Bob Tolbert
fb7c7e5794 Fix #607, remove return from try when there is a generator inside
Added the contains_yield attr to 'try' when the body it is
wrapping contains 'yeild'.

Should also address #600 and #563
2014-06-22 10:50:00 -06:00
Allison Kaptur
a2f917aba3 raise hy compile error on Py2.x for raise from 2014-06-09 16:33:16 -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
James King
8e173937c3 Add shadow.hy to core
This new core module allows us to shadow the builtin Python operators so
they may be passed to sequence functions that expect functions:

    => (map / [1 2 3 4 5])
    [1.0, 0.5, 0.3333333333333333, 0.25]
2014-05-26 21:50:47 -04:00
Abhishek L
c2982a9ae3 anaphoric: fix first & last when conditions fail
* hy/contrib/anaphoric.hy: `ap-first` and `ap-last` now handle cases
  when failure happens for the predicate. Thanks to @tutorto for
  reporting this bug
2014-05-24 17:48:46 +05:30
John MacKenzie
15ad6cb998 defmacro/g! and HyObject#startswith
Currently, defmacro/g! doesn't respond well when it comes across a
HyObject that doesn't respond to the instance method startswith (e.g.
HyInteger, HyFloat, etc.). This updates defmacro/g! to be a little
safer when searching for the gensyms it needs to create.
2014-05-15 01:51:38 +00:00
Tuukka Turto
f6c491d35c Merge branch 'master' into pr/585 2014-05-14 09:02:23 +03:00
Tuukka Turto
726d1735db Merge branch 'master' into pr/571
Conflicts:
	AUTHORS
	tests/native_tests/core.hy
2014-05-13 09:32:51 +03:00
Paul Tagliamonte
2b08674c88 Merge branch 'master' into pr/522 2014-05-12 22:10:09 -04:00
Paul Tagliamonte
1ae666e096 Merge branch 'master' into pr/565 2014-05-12 20:43:09 -04:00
Paul Tagliamonte
ca0271df95 Merge branch 'master' into pr/574
Conflicts:
	AUTHORS
2014-05-12 20:15:51 -04:00
Paul Tagliamonte
1696ddecac Merge branch 'master' into pr/578 2014-05-12 20:14:37 -04:00
Abhishek L
18a6346d42 Display python version & platform at repl startup
*hy/cmdline.py: At the repl startup the Python implementation & version
 is displayed along with the platform(os) information
2014-05-07 01:04:07 +05:30
Abhishek L
4f74652c73 the mega typo fix commit
Wow! much typos! such fix!
2014-05-05 23:47:14 +05:30
Christian Weilbach
01ee54cf62 Merge https://github.com/hylang/hy
Fix butlast and test for disassemble.

Conflicts:
	hy/core/language.hy
2014-05-03 16:33:39 +02:00
Kartik Mistry
909981dd23 Typo fixes in comments
Signed-off-by: Kartik Mistry <kartik.mistry@gmail.com>
2014-05-02 21:31:51 +05:30
Tuukka Turto
b1a928037e Merge branch 'master' into pr/526 2014-05-02 10:34:37 +03:00
Allison Kaptur
1499d49878 Add support for explicit exception chaining
A la PEP 3134
2014-05-01 16:30:40 -04:00
Tuukka Turto
ddcf192da4 Merge branch 'master' into pr/524 2014-04-30 10:16:30 +03:00
Berker Peksag
cdea12b276 Make hy2py public. 2014-04-30 01:51:21 +03:00
Matthew Wampler-Doty
7b5cb390ab setv no longer creates variables with '.' in their names
FIXES #577
2014-04-29 09:22:55 -05:00
pyos
8e4b21103c Reimplement some built-ins in terms of the standard library.
As a result:

  * functions such as `nth` should work correctly on iterators;
  * `nth` will raise `IndexError` (in a fashion consistent with `get`)
    when the index is out of bounds;
  * `take`, etc. will raise `ValueError` instead of returning
    an ambiguous value if the index is negative;
  * `map`, `zip`, `range`, `input`, `filter` work the same way (Py3k one)
    on both Python 2 and 3 (see #523 and #331).
2014-04-29 18:03:43 +04:00
Tuukka Turto
bdd8e3c82e merge #547 - keyword? 2014-04-28 21:59:33 +03:00
Allison Kaptur
3f9ae9122e Raise exceptions when no handlers are provided.
Also small DRYing in try handling.

Previously, writing a bare (try (foo)) would invoke Pokemon
exception catching (gotta catch 'em all) instead of the correct
behavior, which is to raise the exception if no handler is provided.

Note that this is a cute feature of Hy, as a `try` with no `except`
is a syntax error.  We avoid the syntax error here because we don't
use Python's compiler, which is the only thing that can throw
Syntax Errors.  :D

Fixes #555.
2014-04-28 03:08:30 +03:00
Matthew Wampler-Doty
f2f38a1cf8 Refactor for loop to use cond 2014-04-22 16:47:42 -07:00
Matthew Wampler-Doty
5c9a8f8975 Closes #573, restores 0.9.12 for loop behavior (and everyone wins!) 2014-04-22 08:57:18 -07:00
Matthew Wampler-Doty
43f63e9ae7 Shortening docstring 2014-04-21 13:17:40 -07:00
Matthew Wampler-Doty
834b0019a7 Fixing doto to be API compatible with Clojure's doto 2014-04-21 12:35:56 -07:00