Jump to content
FHannes

SCAR Titan 4.00 Pre-Alpha

Recommended Posts

SCAR's development contains 3 branches, the stable branch which is the current release which gets updates to fix bugs and such. Then there's the development branch which adds new features and functions to the current stable version. Finally there's the next gen branch which is basically the development of the next generation SCAR application. The current versions in all of those branches are 3.25.08, 3.26.00 and 4.00.00

 

As all other pre-releases for years, I will be releasing copies of it to the public for SCAR Titan 4.00, which will be about a 50% rewrite from SCAR Divi. SCAR 4 is being written from scratch, but parts are being merged into it from SCAR Divi and SCAR Luna as the development progresses.

 

This first pre-release version is the pre-alpha. This is a highly experimental release and might not always be stable and is also constantly changing. However, even though it currently doesn't have many features or functions, it's already quite functional.

 

What has changed?

 

SCAR 4 removes the usage of include files, these are replaced by units (namespaces). For example, to include a file "Includes\MyFile.scar", you write:

uses MyFile;
begin
end.

This file will be structured like this:

[scar]unit MyFile;

 

interface

 

implementation

 

end.[/scar]

If you want to include files from subfolders, for example "Includes\Folder\MyFile.scar", you need to add "Folder.MyFile" to uses and the unit header has to start with "unit Folder.MyFile".

 

Aside from the above, most (not all) internal functions are divided up into namespaces as well. For example, to use Rnd (Random) which is part of the namespace Math, you have 2 options:

[scar]uses Math;

begin

Print(Rnd(5));

end.[/scar]

[scar]begin

Print(Math.Rnd(5));

end.[/scar]

 

Any changes besides this are mostly additions and to the core library which is being completely renewed. Most language features available before are still available now.

 

What's new?

The number of new features that are already in SCAR 4 and coming in the future is incredibly big, but I'll try to list as many as possible.

 

Variable Initialization

You can now initialize variables:

[scar]var

i: Integer = 5;

begin

Print(i);

end.[/scar]

 

Classes

You can now define classes:

[scar]type

TMyClass = class

private

FInt: Integer;

public

constructor Create;

property Int: Integer read FInt;

end;

 

constructor TMyClass.Create;

begin

inherited Create;

FInt := 5;

end;

 

var

c: TMyClass;

 

begin

c := TMyClass.Create;

try

Print(c.Int);

finally

c.Free;

end;

end.[/scar]

 

Interfaces

You can now use interfaces:

[scar]type

IMyClass = interface

function GetInt: Integer;

end;

 

TMyClass = class(TInterfacedObject, IMyClass)

private

FInt: Integer;

public

constructor Create;

function GetInt: Integer;

end;

 

constructor TMyClass.Create;

begin

inherited Create;

FInt := 5;

end;

 

function TMyClass.GetInt: Integer;

begin

Result := 5;

end;

 

var

c: TMyClass;

 

begin

c := TMyClass.Create;

try

Print(c.GetInt);

finally

c.Free;

end;

end.[/scar]

 

Parameter initialization (optional parameters)

You can now give parameters default values:

[scar]function MyFunc(const i: Integer = 5): Integer;

begin

Result := i;

end;

 

begin

Print(MyFunc);

Print(MyFunc(6));

end.[/scar]

 

Overloading

Functions can now be overloaded in a script by using the overloaded keyword. Many functions in the core are also overloaded to provide a very flexible API.

[scar]function MyFunc(const i: Integer): Integer; overload;

begin

Result := i;

end;

 

function MyFunc(const e: Extended): Extended; overload;

begin

Result := e + 5;

end;

 

begin

Print(MyFunc(5));

Print(MyFunc(5.0));

end.[/scar]

 

Extended record members

Records can now have a lot more members, like a class without "instantiation":

[scar]type

TType = record

public

i: Integer;

procedure SetI(const ii: Integer);

end;

 

procedure TType.SetI(const ii: Integer);

begin

i := ii;

end;

 

var

t: TType;

 

begin

t.SetI(5);

Print(t.i);

end.[/scar]

 

Operator overloading

You can now use operator overloading to assign operations to the operators of your structured types. A lot of types that will be in the core will also have overloaded operators.

[scar]type

TType = record

public

i: Integer;

class operator Add(const t1, t2: TType): TType;

end;

 

class operator TType.Add(const t1, t2: TType): TType;

begin

Result.i := t1.i + t2.i;

end;

 

var

t1, t2: TType;

 

begin

t1.i := 3;

t2.i := 7;

Print((t1 + t2).i);

end.[/scar]

 

Pointers

You can use pointers now!

[scar]type

IntPointer = ^Integer;

 

var

i: Integer = 0;

pi: IntPointer;

 

begin

pi := @i;

pi^ := 5;

Print(i);

end.[/scar]

 

C++ Operators

A bit odd in a pascal based language, they're so awesome:

[scar]var

i: Integer = 0;

begin

i += 2;

Print(i++);

Print(++i);

end.[/scar]

 

Unicode support

You can now use unicode characters in SCAR:

[scar]begin

Print('???????????');

end.[/scar]

 

Ranges

SCAR Titan supports defining ranges:

[scar]type

TMyRange = 0..9;

 

var

r: TMyRange;

 

begin

r := 5;

PrintLn®;

end.[/scar]

 

Sealed classes

You can now use sealed (final) classes:

[scar]type

TMyClass = class sealed

end;

 

TMyClassEx = class(TMyClass)

end;

 

begin

end.[/scar]

 

Final methods

Final methods are available now:

[scar]type

TMyClass = class

public

procedure Tmp; virtual; final;

end;

 

TMyClassEx = class(TMyClass)

public

procedure Tmp; override;

end;

 

procedure TMyClass.Tmp;

begin

// ...

end;

 

procedure TMyClassEx.Tmp;

begin

inherited;

// ...

end;

 

begin

end.[/scar]

 

Abstract classes

You can create abstract classes:

[scar]type

TMyClass = class abstract

public

procedure Tmp; virtual; abstract;

end;

 

TMyClassEx = class(TMyClass)

public

procedure Tmp; override;

end;

 

procedure TMyClassEx.Tmp;

begin

inherited;

// ...

end;

 

begin

end.[/scar]

 

Absolute keyword

You can now use the absolute keyword:

[scar]type

TMyClass = class

public

function Get: string;

end;

TMyClass2 = class

public

function GetStr: string;

end;

 

function TMyClass.Get: string;

begin

Result := 'TMyClass';

end;

 

function TMyClass2.GetStr: string;

begin

Result := 'TMyClass2';

end;

 

var

o: TObject;

c: TMyClass absolute o;

c2: TMyClass2 absolute o;

 

begin

o := TMyClass2.Create;

if o is TMyClass then

PrintLn(c.Get)

else

PrintLn(c2.GetStr);

end.[/scar]

 

And there's surely much more I'm forgetting...

 

SCAR 4 also includes a new IDE, but that's still in the making... Features will include code folding, IDE plugins, advanced debugging features as found in SCAR Divi, ... A new plugin system will also be created, currently however the Legacy.TLegacyPlugin class can be used to import old plugins. The scripts themselves execute averagely 100 times faster than scripts in SCAR Divi because SCAR Divi used an interpreter to run scripts, SCAR Titan compiles them to native machine code and executes it.

 

Documentation can be found here: http://wiki.scar-divi.com/titan/index.php?title=Category:API

 

Finally, the program itself can be found it's it's subversion repository here: http://svn.scar-divi.com/titan/

 

Development is progressing fairly quickly, so you'll see many more functions and other stuff appearing in the application soon.

 

Enjoy!

~Freddy

Edited by Freddy
Link to comment
Share on other sites

Love this.

 

Edit: One thing I noticed is that it shuts down smart as soon as the script is over. Fixes?

 

Can't be fixed, you can remove the FPlugin.Free in the SMART.scar's finalization section, that will keep the plugin from being freed from the memory, however, it will cause a memory leak.

Link to comment
Share on other sites

Love this.

 

Edit: One thing I noticed is that it shuts down smart as soon as the script is over. Fixes?

 

Can't be fixed, you can remove the FPlugin.Free in the SMART.scar's finalization section, that will keep the plugin from being freed from the memory, however, it will cause a memory leak.

 

Just want to inform yall that the problem has been fixed since Freddy rewrote the smart plugin with his new plugin system! :)

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...