Skip to content

Commit 4acb1f8

Browse files
committed
Removes variable-unset! from the interpreters as it is not being used (and not a good idea anyways)
1 parent 9b5ec47 commit 4acb1f8

File tree

5 files changed

+3
-41
lines changed

5 files changed

+3
-41
lines changed

ports-js/scheme.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const _quote = Sym('quote');
1313
const _if = Sym('if');
1414
const _cond = Sym('cond');
1515
const _set = Sym('set!');
16-
const _unset = Sym('variable-unset!');
1716
const _define = Sym('define');
1817
const _lambda = Sym('lambda');
1918
const _begin = Sym('begin');
@@ -102,14 +101,6 @@ export class Env extends Map {
102101
throw new Error(`Variable ${Symbol.keyFor(key)} not found`);
103102
}
104103

105-
unset(variable) {
106-
const key = this.keyFor(variable);
107-
if (this.has(key)) {
108-
this.delete(key);
109-
} else {
110-
throw new Error(`Variable ${Symbol.keyFor(key)} not found`);
111-
}
112-
}
113104
}
114105

115106
// Helper functions
@@ -340,10 +331,6 @@ function evaluate(x, env = globalEnv) {
340331
const [_, variable, exp] = x;
341332
env.find(variable).set(variable, evaluate(exp, env));
342333
return null;
343-
} else if (x[0] === _unset) {
344-
const [_, variable] = x;
345-
env.find(variable).unset(variable);
346-
return null;
347334
} else if (x[0] === _define) {
348335
const [_, variable, exp] = x;
349336
env.set(variable, evaluate(exp, env));

ports-py/lispy.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def Sym(s, symbol_table={}):
2020
if s not in symbol_table: symbol_table[s] = Symbol(s)
2121
return symbol_table[s]
2222

23-
_quote, _if, _cond, _set, _unset, _define, _lambda, _begin, _definemacro, _include, = list(map(Sym,
24-
"quote if cond set! variable-unset! define lambda begin define-macro include".split()))
23+
_quote, _if, _cond, _set, _define, _lambda, _begin, _definemacro, _include, = list(map(Sym,
24+
"quote if cond set! define lambda begin define-macro include".split()))
2525

2626
_quasiquote, _unquote, _unquotesplicing = list(map(Sym,
2727
"quasiquote unquote unquote-splicing".split()))
@@ -187,18 +187,7 @@ def find(self, var):
187187
return self.outer.find(var)
188188
finally:
189189
self.lock.release()
190-
191-
def unset(self, var):
192-
"Unset a variable in the current environment."
193-
self.lock.acquire()
194-
try:
195-
if var in self:
196-
del self[var]
197-
else:
198-
raise LookupError(var)
199-
finally:
200-
self.lock.release()
201-
190+
202191
def __str__(self) -> str:
203192
if self.outer is None:
204193
return "global env"
@@ -312,10 +301,6 @@ def eval(x, env=global_env):
312301
(_, var, exp) = x
313302
env.find(var)[var] = eval(exp, env)
314303
return None
315-
elif x[0] is _unset: # (variable-unset! var)
316-
(_, var) = x
317-
env.find(var).unset(var)
318-
return None
319304
elif x[0] is _define: # (define var exp)
320305
(_, var, exp) = x
321306
env[var] = eval(exp, env)

ports-s/PortsS-Interpreter/PortsScheme.class.st

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ PortsScheme >> evalExprs: element in: env [
8080
at: x second
8181
put: (self evalExprs: x third in: localEnv).
8282
^ nil].
83-
[#'variable-unset!' = x first] -> [
84-
(localEnv find: x second) unset: x second.
85-
^ nil].
8683
[#define = x first] -> [
8784
localEnv at: x second put: (self evalExprs: x third in: localEnv).
8885
^ nil].

ports-s/PortsS-Interpreter/PortsSchemeEnv.class.st

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,3 @@ PortsSchemeEnv >> setBindingsFor: paramOrParams to: arguments [
8080
with: arguments
8181
collect: [:a :b | a -> b]]).
8282
]
83-
84-
{ #category : #accessing }
85-
PortsSchemeEnv >> unset: aSymbol [
86-
87-
bindings removeKey: aSymbol
88-
]

ports/spec.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ A PorTS language implementation should implement the following special forms:
1313
- quote
1414
- cond
1515
- set!
16-
- variable-unset!
1716
- define
1817
- lambda
1918
- begin

0 commit comments

Comments
 (0)