Commit Graph

13 Commits

Author SHA1 Message Date
Kodi Arfer
80eb27906a Update copyright years 2020-01-09 14:05:12 -05:00
Kodi Arfer
308bedbebe Remove uses of defclass attribute lists 2019-07-17 14:34:31 -04:00
Kodi Arfer
62638b44a3 Update copyright years 2019-02-07 08:57:35 -05:00
Kodi Arfer
6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05:00
Kodi Arfer
2eb81864df Make all files comply with license-header policy 2017-04-27 14:16:57 -07:00
Kodi Arfer
18acfe6495 Revert the extension of with-decorator to setv
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.
2017-04-13 06:36:00 +03:00
Kodi Arfer
ae1dd78c53 Make setv always return None 2017-03-24 06:38:30 +02: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
Gergely Nagy
cbc2eed900
defclass reimagined
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>
2015-08-04 16:43:07 +02:00
Matthías Páll Gissurarson
1d5b455491 Added a fix for nested decorators. Fixes #752 2015-01-14 19:42:02 +00:00
Paul Tagliamonte
dcf29d3d2a Fix the test decorator to return the class. 2014-11-15 07:47:55 -05:00
Ryan Gonzalez
c7e4d4cd6e Add tests 2014-11-14 14:21:16 -06:00
Julien Danjou
2ef9a0fdaf Rename decorate-with' to with-decorator'
Fixes #158

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:14:22 +02:00