[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Utkarsh Singh] Undefined simultaneous definitions
From: |
Utkarsh Singh |
Subject: |
[Utkarsh Singh] Undefined simultaneous definitions |
Date: |
Mon, 20 Sep 2021 09:46:43 +0530 |
Note: Resending because previous message doesn't appears in archive.
-------------------- Start of forwarded message --------------------
From: Utkarsh Singh <utkarsh190601@gmail.com>
To: guile-user@gnu.org
Subject: Undefined simultaneous definitions
Date: Mon, 20 Sep 2021 08:45:48 +0530
Hi Guilers,
First of all I would like to thank you for maintaining this wonderful
programming language.
SICP Section 4.3 defines a non-deterministic (or ambiguous) evaluator
which helps in non-deterministic computing. In implementing such an
evaluator I am having difficulty in defining `letrec' special form and
procedure definition with simultaneous internal definition. For
example, consider the following REPL session:
;;; Amb-Eval input:
(define (findout32 x)
(letrec ((even?
(lambda (n)
(if (= n 0)
#t
(odd? (- n 1)))))
(odd?
(lambda (n)
(if (= n 0)
#f
(even? (- n 1))))))
(cond
((even? x) 20)
((odd? x) 30)
(else 40))))
;;; Starting a new problem
;;; Amb-Eval value:
ok
;;; Amb-Eval input:
(findout32 10)
;;; Starting a new problem ERROR: In procedure scm-error:
Unassigned variable -- LOOKUP-VARIABLE-VALUE odd?
I tried to debug this issue using `trace' command and it seems that my
evaluator is *not* correctly evaluating sequence of `set!' expression
generated by `scan-out-defines' (see source file for definition).
For now I am going to attach the following files in order to
sufficiently explain the problem:
1. ambeval.scm (Implementation of evaluator)
2. test-ambeval.scm (Test suite for evaluator)
3. test-letrec.log (Erroneous log generated by test suite for `letrec')
Thank you,
Utkarsh Singh
--
Utkarsh Singh
https://utkarshsingh.xyz/
ambeval.scm
Description: Evaluator
ambeval-test.scm
Description: Test suite
test-letrec.log
Description: Letrec log
-------------------- End of forwarded message --------------------
--
Utkarsh Singh
https://utkarshsingh.xyz/