Commit Graph

72 Commits

Author SHA1 Message Date
redraiment
2b40dea54d Fixes #1875: parse-args requires values to be representable as Hy models
* Update argument spec parse logic of parse-args function.
* Update test case of parse-args function.
* Update document of parse-args function.
* Describe the change in NEWS file.
2020-03-31 10:44:26 -04:00
Kodi Arfer
80eb27906a Update copyright years 2020-01-09 14:05:12 -05:00
Adam Porter
0f3d256ebf Add: parse-args function
Closes #1719.
2019-10-30 10:16:45 -05:00
Kodi Arfer
d32e460531 Remove some exceptions in keyword parsing 2019-07-24 11:21:11 -04:00
Kodi Arfer
308bedbebe Remove uses of defclass attribute lists 2019-07-17 14:34:31 -04:00
Kodi Arfer
9b4178ebd0 Remove undocumented fns integer and string 2019-06-04 14:01:59 -04:00
Kodi Arfer
ea872c3983 Remove native tests of Python 2 2019-06-04 14:01:59 -04:00
Kodi Arfer
e77ce92635 Simplify gensym format 2019-04-29 08:10:51 -04:00
Tristan Cacqueray
d793cee90a add tuple? function hy.core
`tuple?` will test if the argument is an instance of tuple.
2019-04-23 15:25:49 -04:00
Tristan Cacqueray
b0ed103931 add list? function to hy.core
`list?` will test if the argument is an instance of list.
2019-04-09 00:07:10 +00:00
Brandon T. Willard
fb6feaf082 Improve correspondence with Python errors and console behavior
Compiler and command-line error messages now reflect their Python counterparts.
E.g. where Python emits a `SyntaxError`, so does Hy; same for `TypeError`s.
Multiple tests have been added that check the format and type of raised
exceptions over varying command-line invocations (e.g. interactive and not).

A new exception type for `require` errors was added so that they can be treated
like normal run-time errors and not compiler errors.

The Hy REPL has been further refactored to better match the class-structured
API.  Now, different error types are handled separately and leverage more base
class-provided functionality.

Closes hylang/hy#1486.
2019-02-07 13:45:41 -05:00
Kodi Arfer
62638b44a3 Update copyright years 2019-02-07 08:57:35 -05:00
Brandon T. Willard
96f99c29d1 Fix missing import in doc macro expansion 2018-09-24 16:39:13 -04:00
Tuukka Turto
5c720c0110
Merge pull request #1473 from Kodiologist/new-year-2018
Update copyright years
2018-02-05 15:11:59 +02:00
Simon Gomizelj
0cd4df3898 Remove def and standardize on setv 2018-01-21 00:25:33 -05:00
Kodi Arfer
6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05:00
gilch
c4b3d7bcda fix gensym format to start with _ for import * 2017-09-23 23:41:37 -06:00
Ryan Gonzalez
dea99c8b76 Merge pull request #1354 from gilch/comment-discard
add #_ discard syntax
2017-08-19 11:29:57 -05:00
gilch
0f81369deb tests for #_ and (comment ...) 2017-08-04 14:35:11 -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
Kodi Arfer
2eb81864df Make all files comply with license-header policy 2017-04-27 14:16:57 -07:00
Kodi Arfer
ae1dd78c53 Make setv always return None 2017-03-24 06:38:30 +02: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
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
d72abb39f1 Remove uses of let from various tests 2017-02-04 09:07:27 -08:00
Philip Xu
eb8fe0b085 Add test for juxt 2016-12-25 16:57:50 -05:00
Philip Xu
f8a5c151f8 Remove trailing space 2016-12-25 16:56:24 -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
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
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
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
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
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
gilch
66c1f38fcc remove catch in favor of except 2015-08-09 00:53:10 -06:00
gilch
bb00e709ee add partition form to core
the 2 argument version of Clojure's partition.

pre-expand ->> macro in partition

Docstring for partition.

add test-partition

Document partition.
2015-08-05 21:38:11 -06: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
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
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
Paul Tagliamonte
ec593154fe Merge branch 'master' into pr/637
Conflicts:
	hy/core/language.hy
2014-11-15 07:58:56 -05:00
han semaj
99db02668b Fix 'some' (first logical true value or nil) 2014-09-04 21:29:38 +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
han semaj
3f1a24bfe3 Implement interleave and interpose 2014-08-17 14:53:57 +12:00