Commit Graph

238 Commits

Author SHA1 Message Date
Paul‮etnomailgaT‭
3eb6001852 Merge pull request #872 from tuturto/xor
Add exclusive or logical operator
2015-12-12 12:38:14 -05: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
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
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
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
Zack M. Davis
6916eea604 merge branch 'f/empty-cond' 2015-08-18 23:23:00 -07:00
Zack M. Davis
1187353661 merge branch 'f/empty-del' 2015-08-18 23:16:14 -07:00
Gregor Best
c29737d421 Merge pull request #897 from farhaven/eval-args-typecheck
Eval args typecheck
2015-08-18 11:01:36 +02:00
Gergely Nagy
ab7d1be001
Allow an empty (cond)
For easier macro writing purposes, allow an empty (cond), that simply
returns nil. Closes #904.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-08-18 08:57:42 +02:00
Gergely Nagy
e0f5d54a2f
Allow (del) without arguments
To mirror the behaviour of (setv), allow an empty (del) too: one that
shall return nil. Closes #905.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-08-18 08:51:09 +02:00
Ryan Gonzalez
7e611947a4 Allow setv to take no arguments (closes #901) 2015-08-17 17:29:06 -05:00
Gregor Best
503b4e1f81 Tidier checks for eval failure modes 2015-08-12 22:01:20 +02:00
Zack M. Davis
1b5f1f3988 merge branch 'nullify' 2015-08-11 21:51:35 -07:00
gilch
a22e2ca4cc purged null from Hy
we already have `nil`, and `null` was barely ever used.
2015-08-11 16:22:13 -06:00
Gergely Nagy
1327d58882
Add a few tests for various defn corner cases
Closes #302.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-08-10 13:44:11 +02:00
Ryan Gonzalez
a0cb250f24 Fix multi-statement 'for' with 'else' and add test cases for 'else' 2015-08-10 10:16:25 +02:00
Ryan Gonzalez
6c076f76f7 Allow 'for' and 'cond' to take a multi-expression body (closes #868) 2015-08-10 10:14:55 +02:00
gilch
66c1f38fcc remove catch in favor of except 2015-08-09 00:53:10 -06:00
gilch
e8d26f1067 remove throw in favor of raise 2015-08-09 00:52:42 -06:00
Tuukka Turto
ec3874377b Merge branch 'master' of github.com:hylang/hy into xor
Conflicts:
	hy/core/language.hy
2015-08-07 06:30:37 +03:00
Calem Bendell
61e4b9dfed replace slice with cut 2015-08-05 13:17:24 +02:00
Tuukka Turto
eaf1a3023a Change xor to binary function
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.
2015-08-03 05:37:39 +03:00
Tuukka Turto
ca8b6b4fe5 Add exclusive or logical operator
Added xor to complement and, or, not operators. Standard python
falsey/truthy semantics are followed. This implementation works for
two or more parameters.
2015-08-02 23:57:46 +03:00
Morten Linderud
b38ec6b92d Merge pull request #863 from farhaven/read-str
Add read-str
2015-07-31 23:58:16 +02:00
Morten Linderud
b6c3289bbe Merge pull request #824 from kirbyfan64/short-circuit
Make and/or short-circuit
2015-07-31 23:57:25 +02:00
Gregor Best
3f0aaf591b Remove failing test for now 2015-07-30 16:07:25 +02:00
Gregor Best
2d7134a1be Add (read-str) 2015-07-30 16:07:25 +02:00
Ryan Gonzalez
016d25d104 Add one-argument division and rationals (closes #825 and #826) 2015-07-29 13:30:24 -05:00
Zack M. Davis
1297cce4e2 merge branch 'eval-param-types' 2015-07-28 21:18:02 -07:00
Gregor Best
48e654596d Type check eval parameters 2015-07-28 16:49:22 +02:00
Ryan Gonzalez
e54d4becec Add zero- and one-argument versions of 'and' and 'or' (ref. #835) 2015-07-25 18:44:23 -05:00
Ryan Gonzalez
95cef09c6a Make 'and' and 'or' short-circuit (ref. #233, closes #766) 2015-07-25 18:44:16 -05:00
Ryan Gonzalez
736d7a7991 Let setv take pairs of arguments (ref. #844) 2015-07-25 17:45:34 -05:00
Zack M. Davis
d8abfb3653 merge branch 'additional_unpacking_correctness' 2015-07-22 21:26:38 -07:00
Ryan Gonzalez
c94c0e8b50 Add set literals (closes #827) 2015-07-14 23:59:29 +03:00
Gregor Best
dcd23cf494 Add tests for eval with explicit global dict 2015-05-23 13:50:17 +02:00
Zack M. Davis
fb98bf58c4 *args and **kwargs no longer have own args in Python 3.5
Python 3.5's PEP 448 ("Additional Unpacking Generalizations") allows the
iterable- and dictionary- unpacking operators to be used more than once;
the implementation (see https://hg.python.org/cpython/rev/a65f685ba8c0)
gets rid of the optional `starargs` and `kwargs` arguments to `ast.Call`
and `ast.ClassDef`, instead using `ast.Starred` and `ast.keyword`
objects inside of the normal `args` and `keywords` lists,
respectively. This commit allows Hy's `apply` to work correctly with
this revised AST when running under Python 3.5.
2015-05-19 20:08:16 -07:00
Paul Tagliamonte
42983d173f Merge branch 'master' into pr/796 2015-04-30 11:14:54 -04:00
Zack M. Davis
2ad2d5a418 fix keyword lambda values by retaining statements in Result
As reported in issue #748, there was a bug in which passing a lambda
as the value of a :keyword argument would fail—

$ hy --spy
hy 0.10.1 using CPython(default) 3.4.0 on Linux
=> (sorted (range 10) :key (fn [x] (- x)))
from hy.core.language import range
sorted(range(10), key=_hy_anon_fn_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_fn_1' is not defined

The function call would appear in the generated AST without being
preceded by the appropriate function definition corresponding to the
anonymous function argument value in the Hy source, causing either a
NameError (as in the example above), or erroneous reuse of whatever
function was already pointed to by the `_hy_anon_fn_` name referenced
in the list of keywords passed to `ast.Call`.

This commit aims to fix the problem by handling it in same way that
the expression/statement gap is bridged many other places in the
compiler, by adding the compiled value of the keyword argument to the
Result object being built during `_compile_collect`, with the
understanding that any Python statements implied by the argument value
will be appropriately preserved therein.
2015-04-26 15:57:08 -07:00
Ryan Gonzalez
4ead84b058 Add argument destructuring 2015-04-18 12:32:03 -05:00
Christopher Allan Webber
d98e4fd733 Implement keyword argument passing... (foo-func 1 2 :kw1 "bar") works!
This code is heavily, *heavily* based off of Guillermo Vaya
(willyfrog)'s work... instead of defining its own keyword arg though, it
uses the "standard" :kwarg type, which is the main difference from
willyfrog's original branch.

Included tests and some documentation in the tutorial.

Also documented "apply" separately as an example of reproducing
*args and **kwargs.
2014-12-23 14:07:02 -06:00
Gergely Nagy
6b3c552df4 Better error messages for fn/defn w/o arglists
When (fn) or (defn) does not get an arglist as first/second parameter,
emit a more descriptive error message, rather than an ugly traceback.

Fixes #716.

Reported-by: Joakim Tall
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-12-12 13:28:28 +01:00
Paul Tagliamonte
b92c19c73c Merge branch 'master' into pr/579 2014-11-15 08:02:41 -05:00
Abhishek Lekshmanan
1b6c765e97 Merge branch master onto #525
Conflicts:
	hy/core/language.hy
	tests/native_tests/language.hy
2014-10-09 21:28:33 +05:30