From e37a382fe2eab112293c81250495537e94401f75 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 27 Dec 2020 20:47:31 +0900 Subject: [PATCH] basic: string array is a thing now --- assets/disk0/tbas/basic.js | 8 ++++---- assets/disk0/tbas/doc/concepts.tex | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/disk0/tbas/basic.js b/assets/disk0/tbas/basic.js index a8d3a64..de5af06 100644 --- a/assets/disk0/tbas/basic.js +++ b/assets/disk0/tbas/basic.js @@ -719,8 +719,8 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length }}, "!" : {f:function(lnum, stmtnum, args) { // Haskell-style CONS return twoArg(lnum, stmtnum, args, (lh,rh) => { - if (isNaN(lh)) - throw lang.illegalType(lnum, lh); // BASIC array is numbers only + if (Array.isArray(lh)) + throw lang.illegalType(lnum, lh); // NO ragged array! if (!Array.isArray(rh)) throw lang.illegalType(lnum, rh); return [lh].concat(rh); @@ -728,10 +728,10 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length }}, "~" : {f:function(lnum, stmtnum, args) { // array PUSH return twoArg(lnum, stmtnum, args, (lh,rh) => { - if (isNaN(rh)) - throw lang.illegalType(lnum, rh); // BASIC array is numbers only if (!Array.isArray(lh)) throw lang.illegalType(lnum, lh); + if (Array.isArray(rh)) + throw lang.illegalType(lnum, rh); // NO ragged array! return lh.concat([rh]); }); }}, diff --git a/assets/disk0/tbas/doc/concepts.tex b/assets/disk0/tbas/doc/concepts.tex index ee5ccf3..c965127 100644 --- a/assets/disk0/tbas/doc/concepts.tex +++ b/assets/disk0/tbas/doc/concepts.tex @@ -15,7 +15,7 @@ There are six basic types: \emph{number}, \emph{boolean}, \emph{string}, \emph{ \emph{Boolean} is type of the value that is either \codebf{TRUE} or \codebf{FALSE}. Number \codebf{0} and \codebf{FALSE} make the condition \emph{false}. When used in numeric context, \codebf{FALSE} will be interpreted as 0 and \codebf{TRUE} as 1. -\emph{String} represents immutable\footnote{Cannot be altered directly} sequences of bytes. However, you can't weave them to make something like \emph{string array}\footnote{Future feature\ldots\ maybe\ldots? Probably not\ldots}. +\emph{String} represents immutable\footnote{Cannot be altered directly} sequences of bytes. \emph{Array} represents a collection of numbers in one or more dimensions.