Commit Graph

488 Commits

Author SHA1 Message Date
Kodi Arfer
05cfe89dd9 Merge branch 'master' into master 2017-03-09 07:24:07 -08:00
Kai Lüke
80f0e4af14 fix example in documentation to unquote in quasi quote 2017-03-09 15:02:23 +01:00
John Patterson
8fb7706a68 Added class use example to tutorial
I was following along and noticed that it wasn't actually explained how to _use_ the object we just made. I include both the `setv` style of writing the Hy as we've been using in the rest of the docs up to this point and a more LISP-y style use of the object.
2017-03-08 22:39:41 -06:00
Kodi Arfer
8b6a45e43a Remove car and cdr in favor of first and rest (#1241)
* Remove uses of `car` and `cdr` in /hy

* Remove uses of `car` and `cdr` in quote tests

* Remove `car` and `cdr` in favor of `first` and `rest`

I beefed up the documentation and tests for `first` and `rest` while I was at it.

I defined `car` and `cdr` in native_tests.cons so the tests read a bit more naturally.
2017-03-06 10:34:40 -06: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
Tuukka Turto
8b84114869 Document get in nested structure (#1236) 2017-02-24 14:22:27 -08:00
Kodi Arfer
e4a7b317e1 Make fn work like lambda and remove lambda (#1228)
* with-decorator: Allow a `setv` form as the form to be decorated

This feature is of dubious value by itself, but it's necessary to allow `defn` to create a lambda instead of a `def`.

* Make `fn` work the same as `lambda`

That is, allow it to generate a `lambda` instead of a `def` statement if the function body is just an expression.

I've removed two uses of with_decorator in hy.compiler because they'd require adding another case to HyASTCompiler.compile_decorate_expression and they have no ultimate effect, anyway.

In a few tests, I've added a meaningless statement in `fn` bodies to force generation of a `def`.

I've removed `test_fn_compiler_empty_function` rather than rewrite it because it seems like a pain to maintain and not very useful.

* Remove `lambda`, now that `fn` does the same thing
2017-02-22 17:36:52 -06:00
Kodi Arfer
45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +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
f3edeb99ae Allow commas and underscores in numeric literals
You can use them as thousands separators.

This change differs from PEP 515 in that not only does it allow commas in addition to underscores, but it's much more liberal about placement. Any number of underscores or commas can be placed anywhere, even at the start.
2017-02-15 09:03:24 +02:00
Kodi Arfer
1d6de2792e Merge branch 'let-it-be' 2017-02-13 09:19:37 -08:00
Kodi Arfer
3ec919278d Remove let from documentation 2017-02-13 09:12:21 -08:00
Charles de Lacombe
83cdaf0a71 Docs: Hy <-> Python interop fix #1061 (#1218)
* Docs: Hy <-> Python interop fix #1061

I separated the existing text in two sections, with some additional
explanations and a link to Hy's `import`.

* added interop page

* simplified interop section in tutorial

* remove the TODO from interop section in tutorial

Because yay

* Corrections from @Kodiologist

I kept the part about mangling, but added a warning about its incompleteness. I
think it can be useful for somebody who just wants to use a Python module in his
code. Maybe it can be removed when the actual documentation for mangling is
written.

* Added myself to AUTHORS.

I'll do my best to be worthy of it. Thanks for this awesome project!
2017-02-10 17:11:21 -08:00
Jakub Wilk
99d31d153c Use HTTPS for github.com, docs.python.org and notes.pault.ag URLs (#1219)
* Use HTTPS for github.com

* Use HTTPS for docs.python.org

* Use HTTPS for notes.pault.ag
2017-02-07 13:25:40 -06:00
Kodi Arfer
9ca7f49c88 Make xor return single true inputs
The documentation should now be correct (#1214).
2017-02-03 22:25:38 +02:00
Kodi Arfer
2dd1432b07 Docs: add an example of evaluating a string 2017-01-19 09:26:12 -08:00
Kodi Arfer
5df8f38d75 Merge branch 'itertools-docs' 2017-01-04 15:14:04 -08:00
Kodi Arfer
c8171bc0c5 Itertools docs edits 2017-01-04 15:11:54 -08:00
gilch
b9106de1ab list all itertools 2017-01-04 13:04:41 -07:00
Kodi Arfer
99b0bd0424 Remove @rwtolbert from core team
Closes #1197.
2016-12-31 11:05:53 -08:00
Kodi Arfer
407a79591a Remove contrib.flow
It's not tested, and sure enough, a glance at the code suggests that `case` and `switch` will evaluate their first argument once for every clause, which is unlikely to be desirable. I say remove it, but if anybody wants to fix and test and re-add `case` (and change it to a square-bracket syntax like `cond`), be my guest.
2016-12-29 08:35:54 -08:00
Kodi Arfer
8eceb4fe9d Move contrib.anaphoric to contrib.extra 2016-12-29 08:35:41 -08:00
Kodi Arfer
670c5ae7e5 Add hy.extra 2016-12-26 15:39:26 -08:00
Kodi Arfer
d980a4a8ee Remove contrib.alias
I don't see why you'd put this in the standard library. I guess it could be useful for when you're maintaining a library and you want to change the name of a function or macro but keep the old name around for a while so people's code doesn't break immediately. But that's a pretty limited purpose.
2016-12-26 15:39:26 -08:00
Kodi Arfer
0c4d416a37 juxt documentation edits 2016-12-26 13:26:44 -08:00
Philip Xu
7dfb9602f8 Add juxt documentation 2016-12-25 17:02:51 -05:00
Philip Xu
24359336f7 Remove trailing whitespace 2016-12-25 16:59:41 -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
accraze
0379fa1b36 added itertools docs
fixes #954
2016-12-22 16:20:30 -08:00
Kodi Arfer
664ded1a19 profile docs wording edit 2016-12-19 14:44:16 -08:00
accraze
115b7dd5fa Added contrib.profile docs
fixes #1145
2016-12-18 21:10:24 -08:00
Tuukka Turto
e588b4928d add defmacro! and fix macro expansion error message (#1172)
* added defmacro!

* revert #924

#924 had an error and should never have been merged in the first place. (see #903)

* put back import getargspec

Without the `formatargspec` this time.

* Give better error message on failed macro expansion

Better error messages work most of the time. In cases where there are
parameters that aren't valid in Python, error message shown is rather
ugly. But this is better than no error messages at all and such
macros with strange parameter names are rather rare.

* fix flake8 errors

* Minor English improvements
2016-12-14 18:10:46 -06:00
Kodi Arfer
28b9874efd Add an example of using argparse with defmain
Closes #1091.
2016-12-13 08:57:31 -08: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
b3d7069fb3 Merge branch 'seq' 2016-12-08 10:27:33 -08:00
Kodi Arfer
f4b00aed17 More copyediting of sequences.rst
I removed "they aren't suited for infinite sequences" since it seems like in fact they are, as given in some of the examples and the tests.
2016-12-07 16:17:58 -08:00
Kodi Arfer
6bf5ebd8ee Remove some trailing spaces 2016-12-07 16:17:52 -08:00
Tuukka Turto
538d36a7c6 Fix grammar 2016-12-01 00:22:42 +02:00
Tuukka Turto
269218a8fd Merge branch 'master' into seq 2016-11-30 23:41:01 +02:00
Tuukka Turto
00615cef36 Add arity-overloaded defn
Old defmulti has been renamed to defn and extended to detect when it is
used to define regular function and when a arity-overloaded one.
2016-11-29 16:21:31 +02:00
Tuukka Turto
cd90959103 Update version added in docs 2016-11-29 07:22:38 +02:00
Tuukka Turto
aeab485a4f Merge branch 'master' into multimethod 2016-11-29 07:14:54 +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
Paul Tagliamomnte
f644dda0dd Add @Kodiologist 2016-11-21 11:44:00 -05:00
Tuukka Turto
a7f6d1d3f7 Add support for multiple statements in sequences 2016-11-09 08:52:18 +02:00
Tuukka Turto
241d554b0b Add lazy sequences into contrib 2016-11-08 21:23:49 +02:00
Tuukka Turto
bae4d61e04 Fix require to new syntax 2016-11-03 14:32:23 +02:00
Tuukka Turto
77bc767907 Merge branch 'master' into multimethod
Conflicts:
	docs/contrib/multi.rst
2016-11-03 14:06:13 +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
gilch
399d2bcf21 clarify documentation of import (#1121)
* clarify documentation of import

Add a comment showing the equivalent python of the long example, and demonstrate how to get `from` and `as` on the same line.

* add python example comment in last import example
2016-09-25 21:29:53 -06:00
gilch
1d3142c8de change quickstart install from PyPI to GitHub (#1116)
* change Quickstart install from PyPI to GitHub
2016-09-24 15:54:32 -06:00
Jakukyo Friel
d81b71f242 Doc: CLI: mention --spy only works in REPL mode. (#1097) 2016-09-22 15:20:26 +03:00
Jakukyo Friel
35de998871 Docs: Fix rst markup in docs/contrib/loop.rst. (#1098)
In RestrutruedText, double backtick quotes (instead of single
backtick quotes in markdown) are used for code span.
2016-09-22 03:33:32 +03:00
Jakukyo Friel
4db667322c Doc: Fix typo (missing quote) (#1096) 2016-09-22 03:32:35 +03:00
Jakub Wilk
b94211251c Use HTTPS for Wikipedia URLs 2016-09-04 22:35:46 +02:00
Michael Hunsinger
6a452d70a4 Added documentation for walk, postwalk and prewalk 2016-08-20 02:35:02 -06:00
John Clover
93a66c7d5e Remove redundant word (#1077)
_a_ or _some_ would work here, I opted to keep _a_
2016-06-24 15:24:20 -07:00
Jakub Wilk
313dff5548 Fix typo 2016-06-11 01:04:07 +02:00
Jakub Wilk
c6ad179bbb Use HTTPS for *.readthedocs.io 2016-05-15 15:28:23 +02:00
Jakub Wilk
35ea55caaf Update readthedocs domains
From the announcement <http://blog.readthedocs.com/securing-subdomains/>:

> Starting today, Read the Docs will start hosting projects from
> subdomains on the domain readthedocs.io, instead of on readthedocs.org.
[...]
> Projects will automatically be redirected, and this redirect will
> remain in place for the foreseeable future. Still, you should plan on
> updating links to your documentation after the new domain goes live.
2016-05-15 15:27:59 +02:00
Matthew Egan Odendahl
d1fd483e59 minor doc fix 2016-05-12 16:41:26 -06:00
Tuukka Turto
0ef9e9ef3b Modify multimethods to use dispatching function 2016-04-16 13:43:13 +03:00
Jonathan Poltak Samosir
fe4f677ed2 Fixed minor rst error + lowercase 'hy' occurance
- (Seemingly) accidental placement of a character meant that the backticks weren't picked up and displayed nicely.
- Everywhere you refer to 'Hy', it has a capital 'h'. Here it did not.

Fixed up minor grammar issue in one sentence

Fixed minor inconsistency with Python and Hy code

- Added variable assignment before code example
2016-02-28 19:04:13 -08:00
Tim Martin
b3a85801bd Documentation of the &key modifier in (defn) 2016-01-26 20:34:08 +00:00
Jakub Wilk
ea98b944cb Fix typo 2016-01-22 20:21:38 +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
Zack M. Davis
a1cb5e33e7 merge branch 'f/hashbang-doc' 2015-12-09 21:48:38 -08:00
Gergely Nagy
6d00df3932 docs: Add some documentation about #!
Add the #! syntax to the quickstart guide, and to the tutorial as well.
Fixes #992.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-12-09 11:48:44 +01:00
Eleonore9
6ee3b03aa4 Fixed typos 2015-12-09 00:17:16 +00:00
Jakub Wilk
1d16addd2e Fix typos 2015-12-08 14:43:47 +01:00
Morten Linderud
a3bd90390c Merge pull request #987 from digitalvectorz/master
api documentation correction (yield)
2015-11-14 23:46:55 +01:00
Johnathon Sage
ec0eea1277 Update api.rst
(for [[( ... ) ( ... )]] )  --> HyMacroExpansionError: 'for' requires an even number of args.
2015-11-14 16:56:27 -05:00
Johnathon Sage
7dbd3bcf7c Update api.rst
Extra closing '])' in yield "yields 'LexException'
2015-11-14 16:18:53 -05:00
Johnathon Sage
e2614cc24a Update tutorial.rst
Changed case of function call in Macro
2015-11-14 15:48:39 -05:00
Zack M. Davis
5af86d691d merge remote-tracking branch 'endrebak/anaphoric-import-info-missing' 2015-10-18 16:39:58 -07:00
Endre Bakken Stovner
66b16d15f5 Add import anamorphic macros info
Small change thanks to kirbyfan64
2015-10-18 21:15:47 +02: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
Tuukka Turto
6ea6777663 Merge branch 'master' into pr/975 2015-10-17 17:11:31 +03:00
Tuukka Turto
b9eb7721da Merge branch 'master' into pr/974 2015-10-17 17:06:43 +03:00
Csilla Nagyne Martinak
acd98bb79e docs/tutorial: Simplify two examples
As part of the Grand Language Cleanup, a few examples in the tutorial
could be simplified:

* The --init-- function of the defclass example does not need an
  explicit None anymore.
* The apply example in the Hy<->Python interop section can use a
  keyword instead of a string in the last part.

This perhaps closes #971.

Signed-off-by: Csilla Nagyne Martinak <csilla@csillger.hu>
2015-10-17 14:07:32 +02:00
Csilla Nagyne Martinak
d79e56f2ef docs/tutorial: Add a short (require) example
Adds a short (require) example, along with a few words on why macros can't be imported.

Closes #966.

Signed-off-by: Csilla Nagyne Martinak <csilla@csillger.hu>
2015-10-17 13:58:47 +02:00
Csilla Nagyne Martinak
f73c862ffa docs: Document the (keyword) and (name) functions
Closes #733

Signed-off-by: Csilla Nagyne Martinak <csilla@csillger.hu>
2015-10-17 13:56:35 +02: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
Tuukka Turto
af6ac92c0a Add section about macros in tutorial
relates #926
2015-10-03 13:24:43 +03: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
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
Michel Alexandre Salim
49a294e98d Update style-guide.rst
Re-indent `fib` examples to match that in original blog post - "Indentation shall be two spaces, except where matching the indentation of the previous line"
2015-09-23 00:39:08 +07:00
Paul Tagliamonte
fc5d74ba85 Add in documentation for non-base 10 numbers 2015-09-15 12:18:56 -04: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
Tim Martin
818ed5da72 Added documentation for the (keyword?) function 2015-08-31 20:35:37 +01:00
gilch
a06c8a9af9 xi parameter may appear in function position 2015-08-12 08:50:18 -06:00
gilch
0bf1084d8c added xi-forms
These work like Clojure's `#()` anonymous function literals.
2015-08-11 19:11:17 -06:00
Ryan Gonzalez
6c076f76f7 Allow 'for' and 'cond' to take a multi-expression body (closes #868) 2015-08-10 10:14:55 +02:00
Gergely Nagy
54fb0102aa Merge pull request #875 from algernon/glc/defclass
defclass reimagined
2015-08-10 09:39:00 +02:00