Skip to content

Commit 6da530c

Browse files
committed
Updates for 34.5
1 parent 483dfd5 commit 6da530c

File tree

5 files changed

+71
-5
lines changed

5 files changed

+71
-5
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
## [34.5] - 2023-08-19
10+
11+
### Added
12+
13+
- `assert` and `retract` functions restored.
14+
915
## [34.4] - 2023-07-02
1016

1117
### Fixed
@@ -483,7 +489,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
483489
- y-or-n? fixed
484490
- compiler warnings suppressed in CLisp
485491

486-
[Unreleased]: https://github.com/Shen-Language/shen-sources/compare/shen-34.4...HEAD
492+
[Unreleased]: https://github.com/Shen-Language/shen-sources/compare/shen-34.5...HEAD
493+
[34.4]: https://github.com/Shen-Language/shen-sources/compare/shen-34.4...shen-34.5
487494
[34.4]: https://github.com/Shen-Language/shen-sources/compare/shen-34.3...shen-34.4
488495
[34.3]: https://github.com/Shen-Language/shen-sources/compare/shen-34.2...shen-34.3
489496
[34.2]: https://github.com/Shen-Language/shen-sources/compare/shen-34.1...shen-34.2

sources/declarations.shen

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
(set *infs* 0)
4848
(set *hush* false)
4949
(set *optimise* false)
50-
(set *version* "34.4")
50+
(set *version* "34.5")
5151
(set *step* false)
5252
(set *it* "")
5353
(set *residue* [])
@@ -129,7 +129,7 @@
129129
intern integer? input input+ inline include include-all-but it is is! in in-package internal implementation if
130130
head hd hdv hdstr hash get get-time gensym fn function fst freeze fresh fork foreign fix file fail fail-if factorise
131131
findall false enable-type-theory explode external exception eval-kl eval error-to-string error empty? element?
132-
dynamic do difference destroy defun define defmacro defcc defprolog declare datatype cn cons? cons cond concat
132+
do difference destroy defun define defmacro defcc defprolog declare datatype cn cons? cons cond concat
133133
compile cd cases call close bind bound? boolean? boolean bootstrap (intern "bar!")
134134
atom? asserta assertz assoc arity append and adjoin <-address address-> absvector? absvector abort])
135135

sources/prolog.shen

+60
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,66 @@
44

55
(package shen []
66

7+
(define asserta
8+
Clause -> (assert* Clause top))
9+
10+
(define assertz
11+
Clause -> (assert* Clause bottom))
12+
13+
(define assert*
14+
[H <-- | B] Where -> (let F (predicate H)
15+
X (terms H)
16+
N (length X)
17+
Vars (parameters N)
18+
Arity (arity F)
19+
Create (if (= Arity -1)
20+
(do (eval (create-skeleton F Vars)) (put F dynamic []))
21+
skip)
22+
Insert (insert-info F X B [H <-- | B] Where)
23+
F))
24+
25+
(define predicate
26+
[F | _] -> F
27+
F -> F)
28+
29+
(define terms
30+
[_ | Terms] -> Terms
31+
_ -> [])
32+
33+
(define create-skeleton
34+
F Vars -> [defprolog F | (dynamic-default F Vars)])
35+
36+
(define dynamic-default
37+
F Vars -> (append Vars [<-- [call-dynamic (cons-form Vars) [get F dynamic]] (intern ";")]))
38+
39+
(define insert-info
40+
F X B Clause Where -> (let G (gensym g)
41+
Create (eval (append [defprolog G] X [<-- | B]))
42+
Entry [(fn G) | Clause]
43+
Dynamic (get F dynamic)
44+
New (if (= Where top)
45+
[Entry | Dynamic]
46+
(append Dynamic [Entry]))
47+
(put F dynamic New)))
48+
49+
(defprolog call-dynamic
50+
Vars (- [[G | _] | _]) <-- (callrec G Vars);
51+
Vars (- [_ | Gs]) <-- (call-dynamic Vars Gs);)
52+
53+
(define callrec
54+
G [] Bindings Lock Key Continuation -> (G Bindings Lock Key Continuation)
55+
G [X | Y] Bindings Lock Key Continuation -> (callrec (G X) Y Bindings Lock Key Continuation))
56+
57+
(define retract
58+
[H <-- | B] -> (let F (predicate H)
59+
Info (get F dynamic)
60+
(put F dynamic (retract-clause [H <-- | B] Info))))
61+
62+
(define retract-clause
63+
_ [] -> []
64+
Clause [[_ | Clause] | Info] -> Info
65+
Clause [Info | Infos] -> [Info | (retract-clause Clause Infos)])
66+
767
(define compile-prolog
868
F Clauses -> (compile (/. X (<defprolog> X)) [F | Clauses]))
969

sources/toplevel.shen

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
E -> (do (pr (error-to-string E) (stoutput)) (nl 0)))
2020

2121
(define credits
22-
-> (do (output "~%Shen, www.shenlanguage.org, copyright (C) 2010-2022, Mark Tarver~%")
22+
-> (do (output "~%Shen, www.shenlanguage.org, copyright (C) 2010-2023, Mark Tarver~%")
2323
(output "version: S~A, language: ~A, platform: ~A ~A~%"
2424
(value *version*) (value *language*) (value *implementation*) (value *release*))
2525
(output "port ~A, ported by ~A~%~%" (value *port*) (value *porters*))))

sources/types.shen

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
(declare destroy [symbol --> symbol])
5555
(declare difference [[list A] --> [[list A] --> [list A]]])
5656
(declare do [A --> [B --> B]])
57-
(declare dynamic [symbol --> [list symbol]])
5857
(declare <e> [[str [list A] B] --> [str [list A] [list C]]])
5958
(declare <!> [[str [list A] B] --> [str [list A] [list A]]])
6059
(declare <end> [[str [list A] B] --> [str [list A] B]])

0 commit comments

Comments
 (0)