mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
remove true? and false?; lua's truthiness and falsehood is guile's.
* module/language/lua/runtime.scm (true?, false?): Remove, now that #nil is false. * module/language/lua/compile-tree-il.scm: Don't emit calls to true? or false?.
This commit is contained in:
parent
48f7c66a40
commit
ae037892f0
2 changed files with 8 additions and 26 deletions
|
@ -44,10 +44,6 @@
|
|||
"Apply a function in the (language lua runtime) module"
|
||||
(make-application src (ref-runtime src name) arguments))
|
||||
|
||||
(define (make-lua-conditional src condition then else)
|
||||
"Generate a conditional with (@ (language lua runtime) true?)"
|
||||
(make-conditional src (make-runtime-application src 'true? (list condition)) then else))
|
||||
|
||||
(define (make-table-ref src table index)
|
||||
(make-runtime-application src 'index
|
||||
(list table (if (symbol? index) (make-const src (symbol->string index)) index))))
|
||||
|
@ -78,7 +74,7 @@
|
|||
(apply-named-lua-function
|
||||
src "while"
|
||||
(lambda (loop)
|
||||
(make-lua-conditional
|
||||
(make-conditional
|
||||
src
|
||||
condition
|
||||
(make-sequence src
|
||||
|
@ -300,9 +296,9 @@
|
|||
(begin
|
||||
;; if not (var and limit and step) then error() end
|
||||
(if (apply (primitive not)
|
||||
(if (apply (@ (language lua runtime) true?) (lexical variable ,gs-variable))
|
||||
(if (apply (@ (language lua runtime) true?) (lexical limit ,gs-limit))
|
||||
(if (apply (@ (language lua runtime) true?) (lexical step ,gs-step))
|
||||
(if (lexical variable ,gs-variable)
|
||||
(if (lexical limit ,gs-limit)
|
||||
(if (lexical step ,gs-step)
|
||||
(const #t)
|
||||
(const #f))
|
||||
(const #f))
|
||||
|
@ -377,13 +373,13 @@
|
|||
(list left right)))))
|
||||
result))
|
||||
((#:or)
|
||||
(make-lua-conditional
|
||||
(make-conditional
|
||||
src
|
||||
left
|
||||
left
|
||||
right))
|
||||
((#:and)
|
||||
(make-lua-conditional
|
||||
(make-conditional
|
||||
src
|
||||
left
|
||||
right
|
||||
|
|
|
@ -28,11 +28,7 @@
|
|||
#:use-module ((srfi srfi-98) #:select (get-environment-variable))
|
||||
#:use-module ((system base compile) #:select (compile read-and-compile))
|
||||
|
||||
#:export (
|
||||
runtime-error
|
||||
|
||||
;; semantics
|
||||
false? true?
|
||||
#:export (runtime-error
|
||||
|
||||
;; misc
|
||||
value-type->string
|
||||
|
@ -92,16 +88,6 @@
|
|||
(define (runtime-warning string . arguments)
|
||||
(apply format (cons #t (cons (string-append "LUA: RUNTIME WARNING: " string "\n") arguments))))
|
||||
|
||||
;;;;; SEMANTICS
|
||||
|
||||
(define (false? x)
|
||||
"Wrapper for Scheme's false semantics that considers #nil to be false"
|
||||
(or (eq? x #f) (eq? x #nil)))
|
||||
|
||||
(define (true? x)
|
||||
"Inversion of false?"
|
||||
(not (false? x)))
|
||||
|
||||
;;;;; MISCELLANEOUS
|
||||
|
||||
(define (value-type->string x)
|
||||
|
@ -333,7 +319,7 @@
|
|||
|
||||
(define-global (assert v . opts)
|
||||
(define message (if (null? opts) "assertion failed" (car opts)))
|
||||
(if (false? v)
|
||||
(if (not v)
|
||||
(runtime-error message)
|
||||
(apply values (cons v opts))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue