Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guile 2.2 support #326

Merged
merged 2 commits into from Feb 1, 2019
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

Prev
schematic: Fix define-action syntax to make it work with guile-2.2.
When compiled with guile-2.2, make-action() always returned the
same thunk (action()) which made define-action not working since
it redefined make-action() each time it was called by setting new
properties for the same thunk, thus using the last defined
action() for each and every menu item. This didn't affect
guile-2.0 due to, probably, more loose code compilation. The issue
has been fixed by moving thunk creation to define-action syntax
which allows creation of new procedures each time it is evaluated.
  • Loading branch information
vzh committed Jan 29, 2019
commit 2f3d20ed5c4b0a84396b4d5a249b0cdedb3b38ca
@@ -98,16 +98,21 @@
(false-if-exception
(eq? %cookie (procedure-property proc 'gschem-cookie))))

;;; define-action syntax defines a procedure being a result of
;;; calling eval-action! on a dummy thunk with properties returned
;;; by make-action. Those predefined properties include a new
;;; thunk defined by FORMS, which will be the core of the result.
;;; This allows you to invoke an action just by calling it like a
;;; normal function.
(define-syntax define-action
(syntax-rules ()
((_ (name . args) . forms)
(define name (make-action (lambda () . forms) . args)))))
(define name
(lambda ()
(eval-action! (make-action (lambda () . forms) . args)))))))

(define-public (make-action thunk . props)
;; The action is a magical procedure that does nothing but call
;; eval-action! *on itself*. This allows you to invoke an action
;; just by calling it like a normal function.
(letrec ((action (lambda () (eval-action! action))))
(let ((action (lambda () "Dummy action.")))

;; The action data is stored in procedure properties -- most
;; importantly, the actual thunk that the action wraps
@@ -126,9 +131,8 @@
(keyword->symbol (list-ref lst 0))
(list-ref lst 1))
(loop (list-tail lst 2))))



;; Return dummy thunk with properties.
action))

(define (action-thunk action)
ProTip! Use n and p to navigate between commits in a pull request.