It was missing quotes around "Tuukka". Output from hy to confirm everything's good:
```clojure
hy unknown using CPython(default) 3.6.1 on Linux
=> (print "Hello there," "Tuukka")
Hello there, Tuukka
```
This is no longer necessary now that `defn` always produces a `FunctionDef`.
To compensate, I've made small edits to two contrib modules and reverted a small test change.
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.
* 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.
* 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
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.
* 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!
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.
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.
* 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
* 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
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.
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
* 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
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.
- (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
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
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>
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>
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>
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>
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>
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"
Fixed up the documentation language here and there, related to the alias
removals in previous commits.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
defclass now has a new syntax:
(defclass Name [BaseList]
[property value
property value] ;; optional
(defn method [self]
self.property))
Anything after the optional property list (which will be translated to a
setv within the class context) will be added to the class body. This
allows one to have side effects and complex expressions within the class
definition.
As a side effect, defining methods is much more friendly now!
Closes#850.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
xor with more than two input parameters is not well defined and people
have different expectations on how it should behave. Avoid confusion by
sticking with two parameters only.
Added xor to complement and, or, not operators. Standard python
falsey/truthy semantics are followed. This implementation works for
two or more parameters.
The `with-decorator` special form is not the most ergonomic—this commit
introduces a new builtin `#@` reader macro that expands to an invocation
of `with-decorator`. To support this, `reader_macroexpand` is made to
also look in the default `None` namespace, in imitation of how
regular (non-reader) macros defined in hy.core are looked up. The
docstring of `hy.macros.reader` is also edited slightly for accuracy.
This in the matter of issue #856.