CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 38
Releases: jac3km4/redscript
v0.5.29
Compare
[0.5.29] - 2025-07-19
Features
- Adds support for modding on MacOS
- You can install REDscript on MacOS by extracting the MacOS archive and copying all the files to the Cyberpunk Directory:
cp -r ~/Downloads/redscript-v0.5.29-macos/ "/Applications/Cyberpunk 2077"
- MacOS automatically quarantines binaries downloaded from the internet so you need to remove them from the quarantine manually:
xattr -r -d com.apple.quarantine "/Applications/Cyberpunk 2077/engine/tools"
- The game currently does not compile scripts on startup, so in order to actually compile the scripts you can use the bundled script to start the game:
"/Applications/Cyberpunk 2077/launch_modded.sh"
- You can install REDscript on MacOS by extracting the MacOS archive and copying all the files to the Cyberpunk Directory:
Contributors
- jekky
Assets 6
v1.0.0-preview.14
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Pattern matching
Powerful pattern matching for switch
and if let
statements is now supported.
// matching based on a subtype
switch inst {
case let SubclassA { fieldA }:
return fieldA;
case let SubclassB { fieldB }:
return fieldB[0];
}
// consuming an array
while let [.., last] = array {
ArrayPop(array);
}
// safe downcasting
if let myClassInst as MyClass = inst {
}
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method)
Assets 4
v1.0.0-preview.13
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview.12
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview.11
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview.10
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed* - some diagnostics like unused variable check are missing*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview9
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed* - no decompiler*
- some diagnostics like unused variable check are missing*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview8
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed* - no decompiler*
- some diagnostics like unused variable check are missing*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview7
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed* - no decompiler*
- some diagnostics like unused variable check are missing*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift
Assets 4
v1.0.0-preview6
Compare
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...
// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}
Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...
Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}
Implicit ref
The compiler now inserts the ref
type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}
New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
Caveats
This is a pre-release and it's therefore incomplete and unstable. While it can already compile and run a lot of existing code, there are currently some limitations:
case
is now a keyword and can't be used as an identifier- no
@replaceGlobal
annotation* - no static receivers (the ability to call static methods with a receiver)*
- the
ref
type as specified by users is currently completely ignored and instead inserted by the compiler where needed* - no decompiler*
- some diagnostics like unused variable check are missing*
Features marked with an asterisk are planned to be included in the final release.
Planned features
Some additional and not yet implemented features include:
@specialize
annotation for providing specialized implementations of generic data types- enforcement of visibility for user code specifically
- some shortcut for creating instance of classes (most likely generating a static
Create
method) - basic pattern matching based on Swift