Commit Graph

626 Commits

Author SHA1 Message Date
Kodi Arfer
6bf5ebd8ee Remove some trailing spaces 2016-12-07 16:17:52 -08: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
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
584a40d9c0 Update tests to work with Pytho 2.x
In Python 2.x (range 10) is mapped to xrange(10) in Python
terms. However, xrange doesn't support slicing, which caused tests to
fail. By forxing xrange into list, we have slicing available.
2016-11-09 05:07:31 +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
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
9ee9f3a55a Merge branch 'master' into pr/1131 2016-10-20 19:12:33 +03:00
Kodi Arfer
0eb4076768 Require Python 3 for neg? and pos? type tests
Python 2 allows 2 < "hello" and the like.
2016-10-11 20:14:14 -07:00
Kodi Arfer
cd1d12565d Assertion-testing style edit 2016-10-11 15:48:40 -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
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
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
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
timmartin
9d6e04fab0 Keyword arguments to functions are required to be strings (#1023)
See discussion in #961
2016-04-11 18:38:13 +03:00
Zack M. Davis
4cee7b1e10 merge branch 'fix-anaphoric-if' 2016-02-28 19:35:07 -08:00
Tim Martin
ec668b5584 In python 3.3+, generator functions always return a value 2016-01-03 11:08:41 +00:00
Paul Tagliamonte
8d2143177e Overhaul macros to allow macros to ref the Compiler
This allows macros to take a keyword dict containing useful things by
defining a keyword argument. This allows us to pass in new objects
which might be handy to have in macros.

This changeset refactors module_name to become `compiler`, so that we
can pass the compiler itself into the macros as `opts['compiler']`.

This allows the macro to both get the macro name
(`compiler.module_name`), as well as use the compiler to build AST.

In the future, this will enable us to create "super-macros" which return
AST, not HyAST, in order to manually create insane things from userland.

For userland macros (not `defmacro`) the core.language `macroexpand`
will go ahead and make a new compiler for you.
2015-12-23 15:52:47 -05:00
Ewald Grusk
b2a72e2f10 Fix anaphoric macro ap-if. 2015-12-17 15:39:33 +01:00
Gergely Nagy
f24daa7ef9 defreader: Allow strings as macro names
This makes it possible to use strings as the macro name argument to
defreader, which in turn makes it possible to define reader macros with
names that would otherwise result in parse errors.

Such as `#.`.

This fixes #918.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-12-17 13:24:20 +01:00
Paul‮etnomailgaT‭
3eb6001852 Merge pull request #872 from tuturto/xor
Add exclusive or logical operator
2015-12-12 12:38:14 -05:00
Jakub Wilk
1d16addd2e Fix typos 2015-12-08 14:43:47 +01:00
Ryan Gonzalez
7ee7428870 Merge branch 'master' of https://github.com/hylang/hy into kwonly_err
Conflicts:
	docs/tutorial.rst
2015-11-14 20:40:20 -06:00
Ryan Gonzalez
283111b495 Improve error messages related to _storeize 2015-11-13 22:30:48 -08:00
gilch
f4afb0ca7e variadic if
The `if` form now supports elif clauses.
It works like `cond` but without the implicit `do`.
The old `if` is now `if*`

variadic lif now supports "ellif" clauses.

Update if-no-waste compiler to use `if*` properly.

(Sometimes one character is all it takes.)

document if

reword truthiness
2015-10-17 19:51:03 -06:00
Ryan Gonzalez
9e5f881958 Give an error when &kwonly or &kwargs is used in a macro definition (closes #959) 2015-10-16 15:50:55 -05:00
Tuukka Turto
7a2be920fa Merge branch 'master' of github.com:hylang/hy into xor
Conflicts:
	hy/core/language.hy
2015-10-03 17:26:41 +03:00
Gergely Nagy
0a942a069f Support one-arity comparison operators too
Comparison operators such as =, !=, <, >, <=, >= should support a
one-arity version too, and return true in those cases (except for !=,
which returns false).

This closes #949.

Reported-by: Matthew Egan Odendahl
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-10-03 11:01:48 +02:00
Gergely Nagy
32f5d5dea7 Drop a set of brackets from with.
This changes with syntax from (with [[x (expr)] (expr)] ...) to (with
[x (expr) (expr)] ...). Should have no ill side effects apart from the
syntax change.

Closes #852.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-10-01 10:08:04 +02:00
Gergely Nagy
9f88e07e1d Drop a set of brackets from let.
This changes let to use a flat list of symbol-value pairs instead of a
vector of vectors. One side effect is that (let [[a 1] z]) is not
expressible now, and one will explicitly need to set a nil value for z,
such as: (let [a 1 z nil]).

Closes #713.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-10-01 10:08:04 +02:00
Gergely Nagy
9569537f8c Merge pull request #929 from gilch/itertools
Itertools
2015-10-01 10:03:16 +02:00
Gergely Nagy
8ce9c0c313 Merge pull request #882 from algernon/glc/apply-mangle
Teach apply about symbol mangling
2015-10-01 10:02:38 +02:00
Gergely Nagy
6d808bfda9 Merge pull request #881 from algernon/f/defclass-init-auto-nil
defclass should add an implicit nil return to --init--
2015-10-01 10:00:47 +02:00
Jakub Wilk
3a1af0c219 Fix typos 2015-09-29 22:57:36 +02:00
Gergely Nagy
26f342d580 Teach apply about symbol mangling
apply now mangles strings and keywords according to the Hy mangling
rules (by using the same function, now imported from
hy.lex.parser). With this change, if the dict passed to apply has
keywords, strings or quoted symbols, they'll get mangled, to turn them
into proper keys.

This only works for the cases where the keys are directly in the apply
params. A previously deffed dict, or key through a variable will not be
mangled.

This closes #219.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-09-24 09:47:12 +02:00
Gergely Nagy
c89865aaf0 defclass should add an implicit nil to --init-- functions
To make it easier to write --init-- functions, defclass will now check
any (setv) expressions (and its property list), to find any --init--
declarations, and append a nil to the end.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-09-24 09:46:59 +02:00
Berker Peksag
456f33eb7c Merge pull request #938 from paultag/paultag/feature/hex-and-octel
Add hex and octel support to Hy integers
2015-09-16 20:55:05 +03:00
Paul Tagliamonte
e05514bb4e Add hex and octel support to Hy integers
This allows us to parse things like 0xDEADBEEF or 0o080.

Filed as issue #937
2015-09-15 11:27:38 -04:00
Adam Schwalm
f9c3966e65 Remove hard-coded references to 'fn' and 'setv' in errors 2015-09-14 18:37:24 -05:00
Gregor Best
2e1b2ff591 Merge pull request #928 from gilch/partition
Enhanced partition
2015-09-06 16:54:23 +02:00
gilch
6f93de68d7 added remaining itertools
Some names have been changed.
Removed redundant zipwith.
Made `first` and `last` more efficient.
2015-09-03 11:45:55 -06:00
gilch
4896980373 enhance partition 2015-09-02 22:54:24 -06:00
Adam Schwalm
f18007955d Better error messages on invalid macro arguments 2015-08-30 17:14:22 -05:00