B = Just broken. :^)actions. help would somehow work? That might be the first thing ppl might try in a console?> tail? []
RawLogic { cond: false }case native.datatype!.tail? [] would return false.path!, lit-path!, set-path!, and get-path!.TODO.md ;)/red/red* that pushes it herehelp: if the user types it without an argument (which is what many users will do first, I suppose), answer with a short explanation of how to use help. This is what the Red console does too.unset! typeany-type!npm install -g typescript , says + typescript@3.9.3test.ts and tried to run it with node test.ts(node:2711185) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension."type": "module" to package.json and (node:2727770) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/sony/code/Red.js/test.tsnpm i @types/node and then I can tsc --target es2020 test.tswhich finally runs without any errors!.js to every import in every .js file and now **it works**!node test.js but whatever)import, likeError [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/sony/code/Red.js/red-types' imported from /home/sony/code/Red.js/runtime/datatypes/series.js
value? native.number! and any-word! are now located in system/words.and, or, and xor operations for typeset!s.pair!, tuple!, and time! no longer box their values (internal).to action.char! and string!.char!.mold behavior for string! and char!.pick and poke bugs.unset native.union native (paritally).make block!.to action for block!.copy action for string!.Red.js in the browser (not the repl.it that does not work for me BTW). I guess you have in mind to create a self-contained Red.js file. When do you plan to start it since I think it would be awesome (above all in combination with red/view ).test.js (and all other js files) was perfect to execute with node. As a part of the output:red-types.ts:38:6 - error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
38 get word() {
~~~~
red-types.ts:48:6 - error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
48 get word() {
~~~~
…..
514 return ((1n << (7n - (BigInt(byte) & 7n)) & this.bytes) != 0n) != this.negated;
~~
red-types.ts:525:16 - error TS2
…..
tokenizer.ts:48:6 - error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
48 get eof() {
~~~
tokenizer.ts:99:27 - error TS2339: Property 'startsWith' does not exist on type 'string'.
99 const res = this.stream.startsWith(str, this.pos);
~~~~~~~~~~
Found 83 errors.$ tsc -t es2020 test.ts
red.ts:9:28 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.
9 import {readFileSync} from "fs";
~~~~
runtime/actions.ts:29:20 - error TS2307: Cannot find module 'process' or its corresponding type declarations.
29 import {send} from "process";
~~~~~~~~~
runtime/natives.ts:28:6 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
28 if(process == null) {
~~~~~~~
runtime/natives.ts:31:4 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
31 process.stdout.write(RedActions.$$form(ctx, val).toJsString());
~~~~~~~
Found 4 errors.test.js no more works! fs error too, I'm not sure, I need to look.test.js worked.test.js generated bytsc test.js just works fine even after 83 errors of transpilation.tsc: Used for compiling TypeScript to JavaScript.node: Used for running JavaScript.tsconfig.json is in the project directory.@types/node installed.rcqls@macbook-3 ~/tmp/AlanVS/Red.js $ node --version v14.3.0 rcqls@macbook-3 ~/tmp/AlanVS/Red.js $ tsc --version Version 3.9.3 rcqls@macbook-3 ~/tmp/AlanVS/Red.js $ npm i @types/node npm WARN red.js@0.0.7 No repository field. npm WARN red.js@0.0.7 No license field. + @types/node@13.13.9 updated 1 package and audited 1 package in 1.054s found 0 vulnerabilities
npm i @types/node (put above just to check if my install was good).test.js runs properly.tsc --build?red is perfect. Some sort of transpiling red code to js is much more interesting (or simply as you mentionned it in your README executing red code in the browser). Do you have plan for that?rcqls@macbook-3 ~/tmp/AlanVS/Red.js $ tsc --build ./test.ts error TS5083: Cannot read file '/Users/rcqls/tmp/AlanVS/Red.js/test.ts/tsconfig.json'. Found 1 error.
libred.js. In the same spirit [https://opalrb.com/](https://opalrb.com/) is awesome for transpiling ruby to js.tsc —build works. The default target is es5 on my computer and the tsconfig mentionned esnext. So everything is fine with this target.run.ts script that allows us to execute any red file. import Red from "./red";
/* this stuff is temporary */
Red.evalRed(`
get: make native! [[
"Returns the value a word refers to"
word [any-word! refinement! path! object!]
/any "If word has no value, return UNSET rather than causing an error"
/case "Use case-sensitive comparison (path only)"
return: [any-type!]
]
get
]
`);
Red.evalFile("./core/natives.red");
Red.evalFile("./core/actions.red");
Red.evalFile("./core/operators.red");
Red.evalFile("./core/scalars.red");
Red.evalFile("./core/functions.red");
Red.evalFile("./core/interactive.red");
/* ------------------------------------- */
var redfile=process.argv[2];
Red.evalFile(redfile);app.rb (that looks like a repl) in order to include the execution of red file. Even you could create a bashfile which would be some sort of red-console but with typescript/node engine./core/scalars.red the following:number!: make typeset! [integer! float! percent! money!] scalar!: union number! make typeset! [char! pair! tuple! time! date!]
/environment/scalars.red:number!: make typeset! [integer! float! percent!] scalar!: union number! make typeset! [money! char! pair! tuple! time! date!]
money! type but the official Red repo does not yetunset! function argumentsrepl.it updated on the network everytime you update the source, or not? When I go to https://redjs-compiled-repl.theangryepicbanana.repl.run/ I get "not implemented" for many features that you announce as having been implemented. Or do I do something wrong? help without argument errors out, right?date! literals: https://repl.it/@theangryepicbanana/red-date-parsingnegative?, positive?, max, and min natives.binary! literals.map! literals.do now accepts file!s.lit-word! arguments that accept unset! now work.tag! literals.date! literals.skip bug.extract helper function.poke for series! types.percent! behavior.shift native.nan? and zero? natives.absolute, negate, and power actions.make/to actions for integer! and float!.#include directive.pick bug.print now prints values correctly.string! comparison.case bug.to block! for strings and maps.block! and paren! actions.map! keys.pair!s.bitset! internals.form for refinement! values.mold issues for:op!native!action!function!context!object!logic!form/mold support for most remaining datatypes:map!unset!binary!issue!time!tuple!percent!hash!vector!bitset!date!extract gets stuck when presented with a block that does not contain a number of components that is a multiple of the second argument.extract at some point because it used something that I haven't implemented yet (so that's probably why it breaks)demo.red, i > gap-end returns integer 0 (instead of logic false) for i=1 and gap-end=20 interpreted wrongly as true.~/tmp/AlanVS/Red.js $ ./red.sh demo.red RedRed d d d e e e R R R edR dR d d d d R R Re edRedR e d d R R e RedR e d d e d R e e R e d d dR R R edR dR d
rcqls@macbook-3 ~/tmp/AlanVS/Red.js $ node app.js
> 1 > 10
RawInteger { value: 0 }
> 10 > 1
RawInteger { value: 5 }:>= and :>:> :>=
Op {
name: '>=',
func: Native {
name: 'greater_or_equal_q',
docSpec: RawString { values: [Array], multiline: false, index: 1 },
args: [ [Object], [Object] ],
refines: [],
retSpec: null,
func: [Function: $$greater_or_equal_q],
arity: 2
}
}
> :>
Op {
name: 'bits',
func: RawFunction {
name: '',
docSpec: RawString { values: [Array], multiline: false, index: 1 },
args: [ [Object], [Object] ],
refines: [],
retSpec: null,
body: RawBlock { values: [Array], index: 1 },
locals: [],
arity: 2
}
}:> returns different results:> :>
Op {
name: '',
func: RawFunction {
name: '',
docSpec: RawString { values: [Array], multiline: false, index: 1 },
args: [ [Object], [Object] ],
refines: [],
retSpec: null,
body: RawBlock { values: [Array], index: 1 },
locals: [],
arity: 2
}
}> :>
Op {
name: '>',
func: RawFunction {
name: '',
docSpec: RawString { values: [Array], multiline: false, index: 1 },
args: [ [Object], [Object] ],
refines: [],
retSpec: null,
body: RawBlock { values: [Array], index: 1 },
locals: [],
arity: 2
}
}series! types, so now mutation works correctly :thumbsup: insert mostly implementedrepend :tada:)pre1 from the preprocessor.series! types.form/mold for binary! values with an offset.clear action.remove action.insert action for any-list!, any-path!, and any-string!.pad and repend helper functions.email!'s implementation.append for any-list!, any-path!, and any-string!.vector!s.make action for vector!s.change action.insert action.copy action.form/mold internals."de"Math.imul does treat its arguments as 32-bit integers iirc)RawInteger constructor, which is so inefficient that I may as well just give every RawInteger its own Int32Array. Adding a flag for it would also clutter up the codebase quite a bit, and it's a decent disaster as it is already.integer! as well.let str2: string;
if(value instanceof Red.RawWord) {
str2 = value.name;
} else if(value instanceof Red.RawString) {
str2 = value.toJsString();
} else if(value instanceof Red.RawBinary) {
str2 = value.bytes.ref.toString();
} else {
str2 = RedActions.$$form(ctx, value).toJsString();
}final str2 = switch(value) {
case Red.RawWord: value.name;
case Red.RawString: value.toJsString();
case Red.RawBinary: value.bytes.ref.toString();
case _: RedActions.form(ctx, value).toJsString();
};str2 as a constant rather than a regular variable (like in the TS code), which can obviously make the code a bit fasterreflect action for object! and map!.foreach.set-word! and set-path!.get-word! and lit-word! function arguments.lit-word! and lit-path! behavior.string!s because it wasn't needed.to- helper functions.find action for any-string! and typeset!.bind somehowword! is wrong :)system/words table and all the others which are created at runtime when you make an object. Each word has a connection that can be to any of these tables ) but only if it already exists in that table). The interpreter uses this connection to take the value of the word. Bind role is just to change the connection of a word, or the words of an entire block, to another table (object) you express in the form bind WORDs TABLE(object). If the word exists in the target table it will be reconnected. After the binding, all the words value of the block will be taken by the interpreter from this table.offset is an optimization and is not really necessary in principle.Red/JS [] #import [ console: "console" object! [ log: "log" function! [ [variadic] args [block!] return: [unset!] ] ] ] console/log [1 2.3 "abc"] ;=> 1 2.3 'abc' ;-- Resulting JS code: ; console.log(1, 2.3, "abc");
repeat i 100 [ switch 0 [ i % 15 [print "FizzBuzz"] i % 3 [print "Fizz"] i % 5 [print "Buzz"] 0 [print i] ] ]
switch should have reduce in front of it, since switch guards are literals .casewith guards zero? i % 15 etc. switch that'd reduce its contents as it goes through each caseswitch even supports literal values rather than variables. That is, switch by its very name implies dispatching based on a value that may change. It's like saying if true .... Switch already doesn't let you use blocks as values to dispatch on. @meijeru please think on that as a design point and pose it to the community with your thoughts. select-case mezz, which is a dialected version of the old BASIC construct, which makes common dispatching cases on ranges convenient and declarative. between? is one of those tricky things, which has to be considered for pragmatic clarity versus, perhaps, a more rigorously correct interpretation. e.g. do you want to spec ranges as 1..10 10..20 or 1..10 11..20.<= for the upper bound. logic! syntax has existed for a while, but functions are newtype?, won't it?type? it's pretty easy because the actual type system uses class inheritance to emulate Red's hierarchyseries! methods, but they're really only made for Haxe code so they're a lot shorter than implementations of the actual Red functionsself is stored in objects?save-self-object in %object.reds.get and set and was accidentally changing the self value of objects because it's the first entry in their lookup tables>> o: object [who-am-I?: does [self]]
== make object! [
who-am-I?: func [][self]
]
>> o/self
*** Script Error: cannot access self in path o/self
*** Where: catch
*** Stack:
>> o/who-am-I?
== make object! [
who-am-I?: func [][self]
]
>> in o 'self
== nonedate! or raw-string! rules to the tokenizer?raw-string! would probably be the easiest though)