consistency.js

This commit is contained in:
Andrew Morris
2023-03-29 16:22:46 +11:00
parent 2e590a50c3
commit 01db810b54
3 changed files with 24 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ export const orderedFiles = [
'/tutorial/valueSemantics.ts',
'/tutorial/cantMutateCaptures.ts',
'/tutorial/classBehavior.ts',
'/tutorial/consistency.js',
'/tutorial/revertOnCatch.ts',
'/tutorial/strings.ts',
'/tutorial/binaryTree.ts',

View File

@@ -2,7 +2,7 @@ import assert from '../helpers/assert';
const entries = Object.entries(
import.meta.glob(
'./root/**/*.ts',
'./root/**/*.*',
{ as: 'raw' },
),
);

View File

@@ -0,0 +1,22 @@
// ValueScript is not about what we think JavaScript should be. We only deviate
// from JavaScript on things related to value semantics and in a few other
// carefully considered cases.
//
// (It also deviates because of things that aren't implemented yet.)
//
// Otherwise, ValueScript behaves as JavaScript does. Sometimes that includes
// some rather unexpected things:
export default function () {
return [
[] + [], // ""
[10, 1, 3].sort(), // [1, 10, 3]
"b" + "a" + +"a" + "a", // "baNaNa"
];
// JavaScript and ValueScript agree on these.
}
// We're not sure yet where exactly to draw this line. Another notable example
// is `with` syntax, which isn't included. If you have an opinion about what we
// should or shouldn't deviate on, let us know at:
// https://github.com/voltrevo/ValueScript/issues/new