Osy#betaRun it on Osyrin: osyrin.com

Reference

Class

19 pages.

Classes

A class is an in-memory shape — data plus the behaviour that belongs to it — and it never touches the database. That is the whole distinction from an…

App.Implementations<T>()

One new instance of every class in the app's composition — its own and every package's — that implements the interface T. How a kit finds every…

Class inheritance

A class can derive from another class with `class Circle : Shape`, inheriting its fields and its methods to any depth. A value of the derived type…

Comparing classes

`==` on two `class` values asks whether they are the SAME INSTANCE, exactly as C# does: two objects built separately are two objects, however equal…

Copying a class with changes

`with` makes a COPY of a class value and replaces the fields you name. Everything you do not name comes from the value you copied, and the original…

Generic classes

A class can declare type parameters, so one shape serves every type it is used with instead of being copied per entity. The type argument is written…

Interfaces — a contract several types can satisfy

An `interface` declares what a type must do without saying how — methods and property contracts, and no state. A member may carry a default body…

Method overloads

A class can declare several methods with the same name, as long as they differ in their parameter types. Each call picks the one that fits its…

Records

A `record` is a class whose values compare by their MEMBERS rather than by identity, exactly as a C# record does. The positional form `record…

Sequence fields on a class

A class can hold many values in one field — `string[]`, `int[]`, `List<Tag>`, `HashSet<string>`, `Dictionary<string, int>`. The element may be a…

Structs

A `struct` is a VALUE type, as in C#: assigning one, passing one, returning one or putting one in a list stores a COPY, so a change through one name…

Testing which class a value is

`s is Circle` asks which type a value actually is at run time, answering by the value's own type rather than the type it is declared as. A derived…

`params` parameters

`params` lets a method be called with any number of trailing arguments — `Total(1m, 2m, 3m)` — which arrive as one array. It must be the last…

`readonly` fields

A `readonly` field can be assigned only where it is declared or in a constructor of the class that declares it. Everywhere else — a method of the…

`static` methods, `static readonly`, `static class` and extension methods

A `static` member belongs to the type rather than to any instance and is reached on the type name — `Money.Round(x)`, `Limits.Max`. A static method…

class methods

Behaviour attached to a class — a method with a receiver, called as value.Method(). Classes are in-memory values, so a method is the natural place…

class properties

A class member that reads and writes like a field but runs a body on access — a computed value, a validating setter, or an auto-property whose…

constructor

A class declares one constructor — its name is the class name, it takes no return type, and it runs when you write new T(args). The constructor body…

native class — a provider implemented in .NET

A `native class` is a provider whose behaviour is a .NET assembly its package ships. It is declared in Osy# for what the platform needs to know…