From 2a44928eb75d8d91d59b3a65327796062953052c Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sat, 4 Feb 2017 09:54:39 -0800 Subject: [PATCH] Remove `let` Yes, bizarrely, this does require editing the implementation of `defn` a little. Without the import, HyList isn't in scope. Defining `let` made it visible due to black magic regarding automatic import. --- NEWS | 2 ++ hy/core/bootstrap.hy | 16 +++------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 0f4b5f6..2414f89 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ Changes from 0.12.1 [ Language Changes ] + * `let` has been removed. Python's scoping rules do not make a proper + implementation of it possible. Use `setv` instead. * xor: If exactly one argument is true, return it [ Bug Fixes ] diff --git a/hy/core/bootstrap.hy b/hy/core/bootstrap.hy index 8d8a3f8..4b07e91 100644 --- a/hy/core/bootstrap.hy +++ b/hy/core/bootstrap.hy @@ -41,23 +41,13 @@ (defmacro defn [name lambda-list &rest body] "define a function `name` with signature `lambda-list` and body `body`" - (if (not (= (type name) HySymbol)) + (import hy) + (if (not (= (type name) hy.HySymbol)) (macro-error name "defn takes a name as first argument")) - (if (not (isinstance lambda-list HyList)) + (if (not (isinstance lambda-list hy.HyList)) (macro-error name "defn takes a parameter list as second argument")) `(setv ~name (fn ~lambda-list ~@body))) -(defmacro let [variables &rest body] - "Execute `body` in the lexical context of `variables`" - (if (not (isinstance variables HyList)) - (macro-error variables "let lexical context must be a list")) - (if (= (len variables) 0) - `((fn [] - ~@body)) - `((fn [] - (setv ~@variables) - ~@body)))) - (defmacro if-python2 [python2-form python3-form] "If running on python2, execute python2-form, else, execute python3-form" (import sys)