Skip to content

Commit

Permalink
break if to accept only #f as false value #87
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Nov 12, 2020
1 parent 6439b06 commit dd0ae14
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.0.0-beta.9
### Breaking
* throw exception when calling `(-)`
* `if` it now see #f the only falsy value to match Scheme spec
### Features
* add `let-values`, `let*-values` and `define-values` syntax macros
* add `exact-integer?` function
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/devel/assets/lips.svg?raw=true)

[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.8-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&e4066ca117a28b18e452fdc6d55b5ba6ed9927d4)](https://travis-ci.org/jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&6439b06966835ca80f04a08ce88ffb71281d62d3)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&2c48907438a7265935a7b21e6931008d)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
<a href="https://twitter.com/intent/tweet?text=Powerful%20Scheme%20based%20lisp%20language%20written%20in%20JavaScript.%20It%20makes%20life%20easier%20by%20better%20interaction%20with%20JS.%20Use%20full%20power%20of%20JavaScript%2C%20lisp%20and%20npm%20to%20create%20your%20applications%20via%20@jcubic&url=https://github.com/jcubic/lips&hashtags=javascript,opensource,lisp,scheme,language,programming">
Expand Down
14 changes: 7 additions & 7 deletions dist/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2014-present, Facebook, Inc.
* released under MIT license
*
* build: Thu, 12 Nov 2020 12:23:37 +0000
* build: Thu, 12 Nov 2020 17:57:38 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -8586,14 +8586,14 @@
var env = this;

var resolve = function resolve(cond) {
if (cond) {
return evaluate(code.cdr.car, {
if (cond === false) {
return evaluate(code.cdr.cdr.car, {
env: env,
dynamic_scope: dynamic_scope,
error: error
});
} else {
return evaluate(code.cdr.cdr.car, {
return evaluate(code.cdr.car, {
env: env,
dynamic_scope: dynamic_scope,
error: error
Expand Down Expand Up @@ -11270,10 +11270,10 @@

var banner = function () {
// Rollup tree-shaking is removing the variable if it's normal string because
// obviously 'Thu, 12 Nov 2020 12:23:37 +0000' == '{{' + 'DATE}}'; can be removed
// obviously 'Thu, 12 Nov 2020 17:57:38 +0000' == '{{' + 'DATE}}'; can be removed
// but disablig Tree-shaking is adding lot of not used code so we use this
// hack instead
var date = LString('Thu, 12 Nov 2020 12:23:37 +0000').valueOf();
var date = LString('Thu, 12 Nov 2020 17:57:38 +0000').valueOf();

var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date);

Expand Down Expand Up @@ -11310,7 +11310,7 @@
var lips = {
version: 'DEV',
banner: banner,
date: 'Thu, 12 Nov 2020 12:23:37 +0000',
date: 'Thu, 12 Nov 2020 17:57:38 +0000',
exec: exec,
parse: parse,
tokenize: tokenize,
Expand Down
4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -5733,14 +5733,14 @@
}
var env = this;
var resolve = (cond) => {
if (cond) {
return evaluate(code.cdr.car, {
if (cond === false) {
return evaluate(code.cdr.cdr.car, {
env,
dynamic_scope,
error
});
} else {
return evaluate(code.cdr.cdr.car, {
return evaluate(code.cdr.car, {
env,
dynamic_scope,
error
Expand Down
8 changes: 8 additions & 0 deletions tests/core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@
(t.is '|\s| 's)
(t.is '|\x3BB;| )
(t.is '|\x9;\x9;| '|\t\t|)))

(test "if"
(lambda (t)
(t.is (if (newline) 1 2) 1)
(t.is (if 0 1 2) 1)
(t.is (if null 1 2) 1)
(t.is (if () 1 2) 1)
(t.is (if #f 1 2) 2)))

0 comments on commit dd0ae14

Please sign in to comment.